Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Corruptinator | |
Old Version | Published before Godot 3 was released. |
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
RigidBody suppose to use forces, and all the calculations of movements and such are behind the scene for all that i know
rustyStriker | 2017-10-04 09:39