Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Technipion |
Hi,
I’m using move_and_slide
to move my player model (kinematic body) around. I want to prevent it from falling off edges when it’s crouching. Is there a simple way to do that?
The collision shape is a capsule with a cylinder at the bottom (so that the player can slide over small things, but doesn’t slide off edges).
Thx
Edit:
My code:
func _physics_process(delta : float) -> void:
# stuff
process_movement(delta)
# more stuff
func process_movement(delta : float) -> void:
# stuff
# basically the movement code from the Godot FPS tutorial:
hvel = hvel.linear_interpolate(target, accel * delta)
vel.x = hvel.x
vel.z = hvel.z
vel = move_and_slide(vel, Vector3(0, 1, 0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
# some more stuff
Can you show us the code?
Schweini | 2019-04-09 15:22
Thx for your reply. I updated my original question. Do you have any ideas how I could prevent move_and_slide
from falling off edges?
Technipion | 2019-04-10 06:56