So i have the movement and everything but i have 3 Questions
- How do i remove moon-like gravity
- How Do i Make it so when i touch walls it doesnt Like, Lock the character there
- 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))