0 votes

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
in Engine by (204 points)
edited by

RigidBody suppose to use forces, and all the calculations of movements and such are behind the scene for all that i know

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.