Hello! Does anybody by any chance know how to apply sliding for Rigidbodies that works similar to "move_and_slide()
" function in the KinematicBody Node? I would like to make the object not stick to walls like as if it was a spider on a wall, and walking up
slopes without issue.
Here is the code to make it move left or right, it works for Rigidbody:
func _sideway_motion(d):
var velocity = get_linear_velocity()
var sideways = get_global_transform().basis.x
if Input.is_action_pressed("ui_left"):
velocity -= sideways * force
direction = "left"
elif Input.is_action_pressed("ui_right"):
velocity += sideways * force
direction = "right"
else:
velocity = get_linear_velocity()
pass
velocity *= dampen
set_linear_velocity(velocity)
pass