Move object randomly through the game window

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 :smiley:

What sort of random movement do you want, a drifting smooth movement, or stopping and starting?
The simplest random movement would be something like:

The 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.

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 :smiley:

I’m struggling to make this movement smooth. I’d like a movement such as pathfinding, however with a random target. This approach makes my character do incremental movements and seems to be shaking due to the short distance. I may be doing something wrong as well…

I also have some issues while moving objects(enemies) randomly on the scene. Can some one share the code or sample conditions?