+1 vote

So i have the movement and everything but i have 3 Questions

  1. How do i remove moon-like gravity
  2. How Do i Make it so when i touch walls it doesnt Like, Lock the character there
  3. How Do i make it so my character doesnt slide when i release a key

Here's my code for reference

extends RigidBody2D

var Ray_Down
var Ray_Left
var Ray_Right
var Walkspeed = 80
var Runspeed = 20
var Jump = 150
var Player

func _ready():
    set_process(true)
    Ray_Down = get_node("RayCast2D")
    Ray_Left = get_node("RayCast2D2")
    Ray_Right = get_node("RayCast2D1")
    Player = self
    Ray_Down.add_exception(Player)
    Ray_Left.add_exception(Player)
    Ray_Right.add_exception(Player)
    set_mode(2)


func _process(delta):



    if Ray_Down.is_colliding():
        print("Hoi")

    if Ray_Down.is_colliding():
        if Input.is_key_pressed(KEY_W):
            Player.set_axis_velocity(Vector2(0, -Jump))
    if !Ray_Right.is_colliding():
        if Input.is_key_pressed(KEY_D):
            Player.set_axis_velocity(Vector2(Walkspeed,0))
    if !Ray_Left.is_colliding():
        if Input.is_key_pressed(KEY_A):
            Player.set_axis_velocity(Vector2(-Walkspeed,0))
in Engine by (484 points)

Um... what does "walls it doesn't like" mean?

1 Answer

+3 votes
Best answer

You can change the gravity in your project settings. Alternatively you can change the gravity scale of your node from the editor or from script.
To fix your wall problem you want to change the resistance of your RigidBody2D to something less than 1 (like 0.4)

by (62 points)
selected by

Thanks ^^ for the help

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.