[SOLVED] What is wrong with this script?

I’m just testing the direction of an object in the variable “direction”. I move the object in the game and the values of direction are wrong. I expect move the object and hold the direction in the variable “direction”. I am checking the value of the variable “direction” in debug mode and is not correct.

Did you tried this


And maybe you can get the angle of an object by this condition
image

1 Like

first of all, why dont you just change the variable “direction” on key press rather than having separate events?
it would also help to know if this game is a platformer??

2 Likes

Try something like:

Condition: Up key is pressed
Action: Change the text variable of direction of Jugador1: set to “up”

Condition: Up key is released
Action: Change the text variable of direction of Jugador1: set to “idle”

Condition: variable direction of Jugador1 is set to “up”
Action: add an instant force of angle 270 and pixels 400

Unless there is some reason you need that variable set (for example, it’s used elsewhere), then you can set the walk speed in the Object’s settings. The arrows automatically know which direction/angle to go.

Thank you guys, it was just only testing. Debug mode shows a few objects built-in variables, I would like see more like speed, etc. Anyway “angle” built-in object variable always is zero in all projects examples of gdevelop. Is it correct?