[SOLVED:] How to Limit a Scene Variable (What Am I Doing Wrong Here?)

Hello all,

EDIT: Thanks to the wonderful Mixen, and my finally taking the time to figure out the debugger functions, I believe I confirmed that it’s clamp(Variable, MinValue, MaxValue). Correct me if I am wrong. I also had to configure my calculation for the Bombs variable. Doubtful, but if anyone’s interested, let me know if you want to see what the code ended up as etc.

I was proud of myself for thinking I found a way to do this, but alas, I didn’t.

I was proud enough that I found a way to increase the frequency that Obstacles (the bombs) spawn in the Geometry Monster game I made following the tutorial.

(The 2nd event in Challenge Increase works fine this way; Bombs gradually spawn more quickly and more quickly, and I find the balance just right. Still, once it reaches a certain point, I would like to limit/cap it.)

After a certain amount of time, bombs spawn too fast. I want to limit how low the Bombs Scene Variable can go (in an earlier Event, this Bombs Variable is compared to a timer that is reset each time an Obstacle spawns, and works well until I add the Condition below). I tried this, but for some reason just a bunch of Bombs spawn right away:

(I tried different values too, lower and higher, and none seem to work right. What am I doing wrong? I even tried Less Than and all sorts of things ha)

Can someone advise what Condition I can add to this Action (that I know works without the Condition…) so that I can limit the difficulty? I’m thinking a Bomb spawning every 1.3 seconds like the Shapes would be good, but I really just need advise on what Condition/Events I must use to do this. Thanks!

P.S. I suppose I could also limit the amount of possible Obstacle objects on screen at once? But I would think there’s a way to set a minimum value for Bombs variable…

P.S.S. I had read similar threads and they seem to imply the Condition posted above should work…

To limit a variable (not only variable, but any value), use clamp(valueToLimit, maxValue, minValue).


Thank you! Sorry to be a hassle, but where do I add a clamp expression?

At the end of your Event Sheet, add a new event and in that event, add an action to change the value of variable set to clamp(variable, maxValue, minValue)

Thank you!!! Do you know if a value like “2.5” could be added there? I believe called a “Float”? I dunno, I’m learning ha

Either way, thanks so much that essentially solved it

Yeah. It’s called float.

I don’t know, but what goes into trying :wink:?

1 Like

I dunno I must have screwed something up with the spawning function or something ha, I appreciate the help tho!

1 Like