How do I create a random angle for a force?

Hi guys, it’s me again :sweat_smile:
I am having trouble getting a global variable for an angle to work the way I want it to.
So here’s the rundown:

I have a global variable which is called “angle” and is set to randomize between 0 and 360.

I have events setup to where when the scene starts it will give the object (“enemy”) a force of whatever my global variable is set to and a set speed. After it does this, it waits 5 seconds before changing it’s course.

The problem is, instead of going up, or left, or whatever angle is available, it ALWAYS goes right and the sub event does not effect it. (Does not change course after five seconds).

I am thinking it’s a problem with my global variable but it seems correct so I am stumped as to why this is not working.

Help is greatly appreciated :smile:

I think the problem is with the Global variable not updating. A Random value is assigned to the global variable at the start and the value remains constant.

Just add another action in the sub-event to update the Global variable :smiley:


Ah that works, thanks :slight_smile:

1 Like

Glad I could help :smiley: