The UFO player is moving so slow

I’ve set the force factor to ‘500’ and engine.get_frames_per_second is giving me 60 FPS, VSYNC is on, and ive set the max FPS to 60, but its still moving at a slugs pace, you can barely see it moving, why is this? And how will all of this affect the final production game?

Hi Norman,

Can you post the code you are using so we can see it in full and see where the issue might be caused.

Thanks in advance

extends RigidBody2D

# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):

func _physics_process(delta):
	if Input.is_action_just_pressed("right_pressed"):
		apply_force(Vector2(500, 0))
	if Input.is_action_just_pressed("left_pressed"):
		apply_force(Vector2(-500, 0))
	if Input.is_action_just_pressed("up_pressed"):
		apply_force(Vector2(0, -500))
	if Input.is_action_just_pressed("down_pressed"):
		apply_force(Vector2(0, 500))

I’ve seen this before, it’s something that can trip up anybody. Input. has two different member functions to choose from in terms of getting a pressed button:

  • Input.is_action_just_pressed() fires exactly one time; holding the button down does not result in more calls as more physics frames are processed.
  • Input.is_action_pressed() fires once per frame if the button is held down, and this is what you want in this case.

The slow movement you’re seeing is just leftovers from the first frame, like a hockey puck on a rink =)

Also, don’t forget to bring your force numbers back down from your testing values. I’m sure you would’ve figured that out, but I’m mentioning it for the sake of completeness.

1 Like

thank you so much, I can’t believe i didnt notice that lol, I relied on the autocomplete and thought it fetched the one i needed, would never have thought there were two similar sounding functions, thanks again!

1 Like

No problem!

This is why it’s a common slip-up =)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms