Ursina player keeps clipping through ground

458 Views Asked by At

I am making a 3D game in Ursina. But, if the player falls at a great enough height, it will just clip straight through the plane and fall into the void. I'm guessing it is because the player is falling so fast the game doesn't even realize the player collided with the ground. All I'm wondering is if there is a way to fix this.

1

There are 1 best solutions below

3
On

well you can define an update function and make an if condition inside to check if the player's y is lower than 100 then make player.gravity = -1 so that the player floats upwards and if the player.y is too high make player.gravity 1

Code explanation:

from ursina import *
from ursina.prefabs import FirstPersonController

app = Ursina()
player = FirstPersonController()

def update():
    if player.y < 100:
        player.gravity = -1
    if player.y > 300:
        player.gravity = 0.005

app.run()