RandomInRange not working [SOLVED]

Whenever I use RandomInRange, it just uses the first number I put. I am using the Repeat Timer Behavior to repeat an enemy spawn timer, but It only recognizes the first number (e.g. RandomInRange(2,5), only recognizing 2). What’s going on?

Can you provide a screen snip of the action using RandomInRange() and surrounding events?


One is for a ground enemy and one is for a flying enemy. Both have the issue.

bad crop, here’s a better one.

I got the gist from the first one, I only asked for the other events in case they were interfering in some way :smiley:

To confirm what you’re hoping to do - are you aiming to spawn the objects at random intervals, so there’s a random delay between each spawn?

If so, the Repeat timer isn’t the best condition to use.

This is because I believe the problem is caused by a new repeat timer condition being generated every frame, and one of those will be the lowest end of the range. Because the condition is run about 60 times a second, it will look like it’s only using the lowest value.

So you’d be better off doing something like :

2 Likes

Thank you so much! Worked like a charm.