Why does this algorithm doesn't work in gdevelop?

Hello,

Why does this algorithm doesn’t work in gdevelop?

We have a circle:

Its variables:
2

Code:

Why doesn’t it move up and down?

regards,

Because the variable is not updated, Y_Pos only gets a value once at the start.

I’ll need a couple more minutes to really answer you (I’m a beginner too), but I can say that you don’t need to use the variable here


you can just say:
“the y position of Circle > Circle.Y() + 100”

Right. Currently the circle only moves down right? I think I follow

“y position of Circle > Circle.Y() + 100”
Would move down forever, yes.

Do you mean the variable cant get another value?

it can’t because you have
“at the beginning of the scene” condition

try to remove it

There are different solutions, this is one that works and is close to yours.

1 Like

Nice. This should work.

  1. The Y coordinate is inverted, meaning that higher is lower, so you actually move downwards when adding 1 to the Y.

  2. You are changing the variable Direction to “Back”, but the next event check if it is “back”, lowercase letters and uppercase letters matter.

1 Like

Can you please explain more?
I am still confused about how the gdevelop axis works!
It seems like it is not like other engines.
I can’t find any explanation or image about gdevelop axis.
If you have a link to an image or description please send me.

regards,

Thanks for your reply but this code isn’t working.
Have you tested it?

Yes, your reply is the right answer.
Here comes the correct code:

Thanks for all your replies.

1 Like

Yes, if the Direction variable value starts with front or back, it works.
I see it’s working for you now👍

1 Like

X:
Left = goes decreasing (below negative)
Right = goes increasing (past positive)

Y:
Up = goes decreasing (below negative)
Down = goes increasing (past positive)

. . . . . . y: -1000
. . . . . . . . . . ˆ
x: -1000 < —0— > x: +1000
. . . . . . . . . . v
. . . . . . y: +1000

1 Like

You have it as set to circle.y()+1 change it to add 1 and it will move

And use subtract for the other way not set to