YesNoOk
avatar

How do < and > work in Mugen exactly? (Read 4297 times)

Started by WastedCoder, June 13, 2022, 02:02:14 PM
Share this topic:
How do < and > work in Mugen exactly?
#1  June 13, 2022, 02:02:14 PM
  • **
    • Ukraine
Code:
trigger1 = cond(enemynear, vel y < 0, (p2bodydist y = [-85,10]), (p2bodydist y = [-33,10]))

I have this piece of code put in the AI. I want it to be able to catch the opponent midair. I wonder if I am using the right condition for this.

I feel like I am not aware how < and > work in Mugen.

Does
Code:
Vel y > -5
mean -4, -3,-2 and so on, like in mathematics, or is it -6, -7, -8? It may sound like a stupid question, 'cause it is, but I wouldn't mind hearing the answer to that just to make sure.

And if you possibly have a better way to keep the track of opponent while his is midair I would be grateful. Because the higher is the opponent, the bigger speed he will have before landing. At first, his y velocity is -1, then -2, -3, -4 and so on.  [/size]
Re: How do < and > work in Mugen exactly?
#2  June 14, 2022, 06:34:18 AM
  • *
Yes. The operators works the same as one would expect in maths.  So you are right in that y >-5 means -4,-3,-2,-1,0,1,2,etc..
Negative velocities are in the upward directions.  Keep in mind though that velocity is a vector so, vel= -4 is greater than vel= -2 but numerically, -4 is less than -2. Operators such as < and > only look at the numeric value.

Also, You code looks like it's to intercept p2 while you are in the air regardless of whether p2 is on the ground or in the air.  It's all good if that's what you want but you'll have to re-state the range if you want it to trigger only when p2 is exclusively in the air.
Re: How do < and > work in Mugen exactly?
#3  June 14, 2022, 08:28:47 AM
  • **
    • Ukraine
Yes. The operators works the same as one would expect in maths.  So you are right in that y >-5 means -4,-3,-2,-1,0,1,2,etc..
Negative velocities are in the upward directions.  Keep in mind though that velocity is a vector so, vel= -4 is greater than vel= -2 but numerically, -4 is less than -2. Operators such as < and > only look at the numeric value.

Also, You code looks like it's to intercept p2 while you are in the air regardless of whether p2 is on the ground or in the air.  It's all good if that's what you want but you'll have to re-state the range if you want it to trigger only when p2 is exclusively in the air.

I got it, thank you! ^-^
Re: How do < and > work in Mugen exactly?
#4  June 14, 2022, 03:56:33 PM
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
I'm just going to chime in real quick comment.

From my experience, I occasionally ran into bugs when float and int values were not handled properly.

Velocity is a float, so you should always try to make the values express as floats.

ex: Vel y > -5.0
trigger1 = cond(enemynear, vel y < 0.0, (p2bodydist y = [-85,10]), (p2bodydist y = [-33,10]))

You probably don't have any bugs with your examples.
There's just certain combinations of triggers/parameters that will not process correctly unless the values are expressed properly... and it will drive you insane trying to figure out what the heck is causing this bug?!

So, it's just a good habit to get into.

Re: How do < and > work in Mugen exactly?
#5  June 14, 2022, 06:33:57 PM
  • **
    • Ukraine
I'm just going to chime in real quick comment.

From my experience, I occasionally ran into bugs when float and int values were not handled properly.

Velocity is a float, so you should always try to make the values express as floats.

ex: Vel y > -5.0
trigger1 = cond(enemynear, vel y < 0.0, (p2bodydist y = [-85,10]), (p2bodydist y = [-33,10]))

You probably don't have any bugs with your examples.
There's just certain combinations of triggers/parameters that will not process correctly unless the values are expressed properly... and it will drive you insane trying to figure out what the heck is causing this bug?!

So, it's just a good habit to get into.

I'm always grateful to get these useful bits of information from much more experienced people. Thank you ^^