# Problem with RigidBody2D

Attention Topic was automatically imported from the old Question2Answer platform.
Old Version Published before Godot 3 was released.

I working on trying to get some basic character movement going. I looked up a few tutorials and came up with this code:

``````extends RigidBody2D

export var speed = 600
export var jump = 10000
var ground = null

#button variables
var up = Input.is_action_pressed("up")
var left = Input.is_action_pressed("left")
var right = Input.is_action_pressed("right")

set_fixed_process(true)
ground = get_node("RayCast2D")

func _fixed_process(delta):
up = Input.is_action_pressed("up")
left = Input.is_action_pressed("left")
right = Input.is_action_pressed("right")
if up && ground.is_colliding():
jump()
elif left:
walk_l()
elif right:
walk_r()
else:
idle()

func idle():
set_axis_velocity(Vector2(0,0))

func walk_l():
set_axis_velocity(Vector2(-speed,0))

func walk_r():
set_axis_velocity(Vector2(speed,0))

func jump():
set_axis_velocity(Vector2(0,-jump))
``````

I have two problems:

1. the speed and jump variables don’t seem to have any effect at all as to how the character moves, as long as there’s a number there, and the positive/negative is right (even if zero, so a -0 will jump, and a 0 doesn’t jump, a -100000000 and a -1 will jump the same height and speed). Changing the mass does seem to have an effect on how ti moves though.
2. My character falls over whenever I move it.

My character so far is just a single sprite with a rectangle CollisionShape2D (scaled from the resource manager) and a raycast pointing down to check for the ground. Anyone have any guesses as to what I’ve done wrong?

Re: 1:
Why do you have -jump inside jump()? Why the negative?
Perhaps you could try to use `set_linear_velocity` instead - try and see if that improves

Re: 2. :