0 Favourites

# minimum TO maximum?

This forum is currently in read-only mode.
• 9 posts
• Hi all,

Is there a way to make a mathematical formula that checks for any value between a set minimum and maximum number?

Specifically what i want done is this:

+ Dude: overlaps Tile : offset (100 TO 200, 40 TO 80)

-> Dude: make stuff happen!

Thanks!

• You could use subevents, although i don't know what you mean by offset.

Dude overlaps tile-

subevent { - Offset is greater than 100,

+ Offset is less than 200,

subevent - { Offset is greater than 40

+ offset is less than 80}}:

Stuff happens here.

Not entirely sure what you're doing but i think that would work?

• The offset was just an example (picked "Copy as text" on an event with the condition "Is overlapping at offset" and edited it to fit what i wanted).

I need this as an algorithm for one condition, not only for the offset condition. My understanding of math is very low, but an algorithm like this shouldn't be too complex for those who do, i hope.

I hope my request is making sense

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• You're probably better off using a detector sprite in this situation, otherwise you would have to have many overlapping at offset checks. Overlapping at offset can't really use a range of values for the x and y offsets, because it uses the sprite as the collision checker, as opposed to just checking if numbers are within a range. Sure, you could make a For loop to iterate through all the offsets, but that'll use a lot more collision checks, and be slower.

• thanks, i guess that's what i'll do in this case. it would be nice if this feature was added, though; i've found myself wanting to do similar things before, not using the offset condition.

• Is there a way to make a mathematical formula that checks for any value between a set minimum and maximum number?

I'm responding to this question in general, since it seems that the overlapping condition is not the only case you are looking to use. That would be a bit complicated and inefficient, as mentioned.

In case you don't know of this, and you just want to check if a variable is within a certain range, there are two easy ways to do that. The System conditions Number is between... and Evaluate can be used to do so:

+ System: Sprite.Angle is between 5 and 10

-> Do stuff...

+ System: Sprite.Angle >= 5 and Sprite.Angle <= 10

-> Do stuff...

Of course, you can use any variable for any of the numbers there, as well.

• thanks a lot, that's exactly what i wanted to know

• Theres also...

``````Clamp(Value, Lower bound, Upper bound)
Returns Value if it is between Lower bound and Upper bound. Returns Lower bound if Value is less than Lower bound. Returns Upper bound if Value is greater than Upper bound [/code:2q4kqde4]``````
• thus:

if 'x' equals clamp('x',min,max)

• do stuff
• 9 posts