Ask here your questions to get help using GDevelop.
By xisco
#70004 Hi,
I'm working on my first game and want to move a sprite (object) randomly around the screen, I've looking the tutorials with gdevelop but I don't have idea about how to do it.
Any help would be appreciate :D
Thanks
By MattLB
#70006 What sort of random movement do you want, a drifting smooth movement, or stopping and starting?
The simplest random movement would be something like:

Code: Select allThe timer "randmove" is greater than 1 second  |  Add to myobject a force, angle:Random(360) and length: 300+Random(100) pixels


This will change the direction and speed of myobject once a second. If you want movement at a constant speed just leave off the "+Random(100) pixels".

If you didn't want 360 degree movement you could change "Random(360)" to "myobject.Angle()+Random(90)" and it would then only deviate slightly from the direction it was already moving, rather than possibly going back the way it came.

You would also need to reset the timer each time of course.
By xisco
#70023 hi, thanks. My idea is to change direction of the movement randomly and bounce on the window borders.
I think your code should help me!! thanks :D
MattLB wrote:What sort of random movement do you want, a drifting smooth movement, or stopping and starting?
The simplest random movement would be something like:

Code: Select allThe timer "randmove" is greater than 1 second  |  Add to myobject a force, angle:Random(360) and length: 300+Random(100) pixels


This will change the direction and speed of myobject once a second. If you want movement at a constant speed just leave off the "+Random(100) pixels".

If you didn't want 360 degree movement you could change "Random(360)" to "myobject.Angle()+Random(90)" and it would then only deviate slightly from the direction it was already moving, rather than possibly going back the way it came.

You would also need to reset the timer each time of course.