0 votes

As the title says, I have a strange problem.
Here is my code:

func _process(delta):
# dont ask about this part pls
var player_pos = get_node("player").get_pos()

if (Input.is_action_pressed("player_move_right")):
    player_pos.x += -PLAYER_SPEED * delta

if (Input.is_action_pressed("player_move_left")):
    player_pos.x += PLAYER_SPEED * delta

if (Input.is_action_pressed("player_move_up")):
    player_pos.y += -PLAYER_SPEED * delta

if (Input.is_action_pressed("player_move_down")):
    player_pos.y += PLAYER_SPEED * delta


Now, if I press for example the "player_move down key", the sprite moves to the left.
I would be happy if you could help me.
I know I could just switch the x's and y's, but it is strange anyway.

in Engine by (37 points)

Ok. It seems that this is a bug:
The player was instantiated in the main scene and the control script is attached to the player.
Then I moved the player node with the script directly into the main scene and it worked somehow.

Is hard to say what is happening there, more details on the scene structure and what is the "player" will be useful.

It might be happpening because you scaled or rotated the parent of the node you are trying to control, or you assigned wrong keys in the control map. The problem is elsewhere.

Please log in or register to answer this question.

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 Frequently asked questions and 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.