Add_central_force pushing rigidbody the wrong way

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alskdjfhg

I have a rigidbody that I move with

if Input.is_action_pressed(“Forward”):
if Input.is_action_pressed(“Left”):


The problem is that when I move it left, right, up, or down it starts moving forward too, even though as far as I can tell there’s no reason for it to

can you supply more code and in “code format” to debug and forward is -x?

klaas | 2020-07-23 11:04

GitHub - frenchma/Game-stuff

this is all the code I’ve got in the file

alskdjfhg | 2020-07-23 18:59

I’ve tested it … no forward movement in my case.
Are your sure that you dont messed up the keybindings?
Maybe you have the forward key bindet to the other directions too!?

klaas | 2020-07-23 19:14

The keybinds are all good, maybe it has something to do with the physics?

I’ve zipped up the game files and stuck that on the github, if anyone wants to take a look

alskdjfhg | 2020-07-23 19:53

:bust_in_silhouette: Reply From: klaas

Ah, now i see.

The problem is the force vector. You have add_central_force in a global direction but you have to remove your global offset (global.origin)

if Input.is_action_pressed("Port"):
if Input.is_action_pressed("Starboard"):

this does the trick.