根据 KinematicBody: Stopping on Slopes :: Godot Recipes (kidscancode.org) 做的斜面的站立
在斜坡上停下时,会跳动是因为有一个向上的力未释放,所以理论上平滑移动就可以解决这个问题
所以根据 hi小胡 的 【Godot】教你实现3D第一人称控制哔哩哔哩bilibili 做了一个平滑移动
但是站到斜面上向上滑动一段后,又会往下滑一段,问一下怎么解决
func _process(delta):
if Input.is_action_pressed("W"):
location -= transform.basis.z
elif Input.is_action_pressed("S"):
location += transform.basis.z
if Input.is_action_pressed("A"):
location -= transform.basis.x
elif Input.is_action_pressed("D"):
location += transform.basis.x
acceleration = acceleration.linear_interpolate(location * velocity ,6 * delta)
motion.x = acceleration.x
motion.z = acceleration.z
motion.y += -delta * gravity
motion = move_and_slide(motion, Vector3.UP, true, 45)