YesNoOk
avatar

Custom State walking (Var Newbie) (Read 996 times)

Started by Plum, April 23, 2019, 07:57:33 pm
Share this topic:
Custom State walking (Var Newbie)
#1  April 23, 2019, 07:57:33 pm
  • **
  • Variables > Boyfriends
Learning to code a transformation, everything was going smoothly until I tried coding the walk cycle. It freezes at frame one and just slides.
The changanim is were the issue seems to be coming from, bascially the  "Vel X < "0  &  "Vel X > 0" the issue being that when animation 30 and 31 are active that can't play past the first tick regardless of the number of frames. Any help would be appreciated.

Here's the code:

[Statedef 20]
type    = S
physics = S
sprpriority = 0

[State 20, 1]
type = VelSet
triggerall = var(10) = 0
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
triggerall = var(10) = 0
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)

[State 20, 1]
type = VelSet
triggerall = var(10) = 1
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)+.2

[State 20, 2]
type = VelSet
triggerall = var(10) = 1
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)+.2

[state 0, 0]
type = changeanim
trigger1 = anim = 5
trigger1 = var(10) = 1
value = 7

[state 0, 1]
type = changeanim
triggerall = Vel X > 0
trigger1 = anim != 20+var(10) && anim != 5+(1*var(10))
trigger2 = anim = 5+(1*var(10)) && animtime = 0 ;turn anim over
value = ifelse(var(10)=0,20,30)

[state 0, 1]
type = changeanim
triggerall = Vel X < 0
trigger1 = anim != 21+var(10) && anim != 5+(1*var(10))
trigger2 = anim = 5+(1*var(10)) && animtime = 0 ;turn anim over
value = ifelse(var(10)=0,21,31)
Last Edit: April 25, 2019, 08:35:58 am by Chartreuse
Re: Custom State walking (Var Newbie)
#2  April 23, 2019, 09:48:57 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Your changeanim codes should have parenthesis around some parts (the ones before "&&").  I changed the code a bit in my suggestion below anyway, though.

The math was not correct in the triggers because it was checking for the wrong anims... "+var(10)" is either adding 0 or 1, but I think you want to be checking by adding either 0 or 10   But you might as well just specify the anims rather than have Mugen do the math.

"IfElse" is generally obsolete compared to "Cond", there's very rarely any practical use for it.

Another thing to note... when doing math with float values, you should generally try using the same # of decimal places for everything in the equation.
In my experience, certain parameters have failed on me when pairing integers and floats.
So if you look at your constants and your walk velocities have 2 decimal places (example: 3.15) then you should be adding 0.20
If your constant walk speed is "3", then you should probably multiply the const by 0.0 before adding 0.2 to it (as I did below)

I also consolidated some code.


Try this:

[Statedef 20]
type    = S
physics = S
sprpriority = 0

[State 20, 1]
type = VelSet
trigger1 = command = "holdfwd"
x = (const(velocity.walk.fwd.x)*0.0) + Cond(var(10),0.2,0.0)

[State 20, 2]
type = VelSet
trigger1 = command = "holdback"
x = (const(velocity.walk.back.x)*0.0) + Cond(var(10),0.2,0.0)

[state 20, 3]
type = changeanim
trigger1 = anim = 5 && var(10)
value = 7

[state 0, 1]
type = changeanim
triggerall = Vel X > 0
trigger1 = anim != 5 && anim != 7 && anim != 20 && anim != 30 ;not turning or walking
trigger2 = (anim = 5 || anim = 7) && animtime = 0 ;turning, turn anim over
value = Cond(var(10),30,20)

[state 0, 1]
type = changeanim
triggerall = Vel X < 0
trigger1 = anim != 5 && anim != 7 && anim != 21 && anim != 31 ;not turning or walking
trigger2 = (anim = 5 || anim = 7) && animtime = 0 ;turning, turn anim over
value = Cond(var(10),31,21)

Last Edit: April 23, 2019, 10:02:56 pm by altoiddealer
Re: Custom State walking (Var Newbie)
#3  April 23, 2019, 10:02:46 pm
  • **
  • Variables > Boyfriends
Thanks for trying, but the animation still gets stuck at the first frame. I'm trying to have 30(walk forward) and 31(Walk Backwards) display properly. Var 10 is the original var I've set for the character(var) within [statedef -3] at the start of the (pre)round, so once they enter their transformed state,( code below) after I taunt; the character's stance and crouch are fine but the walking animations are just sliding and forever in "animelem 1" which is what I'm trying to solve.

[Transformation Code within Taunt]
[State 0, VarSet]
type = VarSet
trigger1 = time = 0
v = 10    ;fv = 10
value = 1

I really do appreciate the effort though! I'll keep trying for a days until I decide to try and reverse engineer Dark Sakura's transformation states in mugen. I'd like to understand how (var) functions without having to copy/dissect another character again.^^"
Re: Custom State walking (Var Newbie)
#4  April 23, 2019, 10:26:41 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Do the walking animations work when var(10) = 0?

Re: Custom State walking (Var Newbie)
#5  April 23, 2019, 10:33:15 pm
  • **
  • Variables > Boyfriends
Yep, just fine so far.

I'm not sure if this will help, but this is the statedef. I was watching a transformation tutorial vid and this was the var it used.

[State -3, VarSet]
type = Varset
trigger1 = roundstate = 0
v = 10
value = 0

Everything works fine before the transformation, which makes it odd, except for the turning animation,(animation 5), but that just loops. Shouldn't be too hard to fix. I'm honestly just worried about the transformed walking animations honestly.
Re: Custom State walking (Var Newbie)
#6  April 23, 2019, 11:02:52 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
So if you hit Ctrl+D to bring up debug, you're saying that when you walk forward the anim changes to anim 30, and the character walks forward, but it is frozen on the first animelem?

Re: Custom State walking (Var Newbie)
#7  April 23, 2019, 11:17:41 pm
  • **
  • Variables > Boyfriends
Mhmm, that's exactly the issue, I honestly hope I'm missing something simple.
Re: Custom State walking (Var Newbie)
#8  April 24, 2019, 07:54:18 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Go down the simple route then. Double up the changeanims and use a triggerall on the correct var value. One set of changeanim for transform  and another for normal. If it still freezes then check that your animation is set up right.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: Custom State walking (Var Newbie)
#9  April 24, 2019, 09:52:29 am
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Also check anim 30 in the AIR, ensure that the animation is correct and that there are no frames with a -1 time
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: Custom State walking (Var Newbie)
#10  April 24, 2019, 05:38:11 pm
  • **
  • Variables > Boyfriends
Thanks for trying to help, but I already did that, I'm only a complete newb with var and changanim. When i set triggerall to "time= 0" the walking animation plays fine, but that changes both walking animations to 30 for walking forward and back which turns into moonwalking when the character moves backwards.

I'll just try the Cyanide approach and see if I'm successful there, appreciate the replies everyone.
Re: Custom State walking (Var Newbie)
#11  April 24, 2019, 06:23:32 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
What Cyanide suggested... if this does not work then there is probably an issue with the anim itself.  Otherwise, the only other explanation really is that some other code in your constant states is screwing with anims 30 and 31.

[Statedef 20]
type    = S
physics = S
sprpriority = 0

[State 20, 1]
type = VelSet
trigger1 = command = "holdfwd"
x = (const(velocity.walk.fwd.x)*0.0) + Cond(var(10),0.2,0.0)

[State 20, 2]
type = VelSet
trigger1 = command = "holdback"
x = (const(velocity.walk.back.x)*0.0) + Cond(var(10),0.2,0.0)

[state 20, 3]
type = changeanim
trigger1 = anim = 5 && var(10)
value = 7

[state 0, 1]
type = changeanim
triggerall = !var(10)
triggerall = Vel X > 0
trigger1 = anim != 5 && anim != 20 ;not turning or walking
trigger2 = anim = 5 && animtime = 0 ;turning, turn anim over
value = 20

[state 0, 1]
type = changeanim
triggerall = var(10)
triggerall = Vel X > 0
trigger1 = anim != 7 && anim != 30 ;not turning or walking
trigger2 = anim = 7 && animtime = 0 ;turning, turn anim over
value = 30

[state 0, 1]
type = changeanim
triggerall = !var(10)
triggerall = Vel X < 0
trigger1 = anim != 5 && anim != 21 ;not turning or walking
trigger2 = anim = 5 && animtime = 0 ;turning, turn anim over
value = 21

[state 0, 1]
type = changeanim
triggerall = var(10)
triggerall = Vel X < 0
trigger1 = anim != 7 && anim != 31 ;not turning or walking
trigger2 = anim = 7 && animtime = 0 ;turning, turn anim over
value = 31

Re: Custom State walking (Var Newbie)
#12  April 25, 2019, 08:35:20 am
  • **
  • Variables > Boyfriends
Thanks to this I was able to at least understand the issue, and I've since been adding more moves to test and the character is coming along well, animations and all.

Thank you, Altoiddealer!

I've never posted and not received a response here, so thanks Cyanide and XGargoyle as well.~
Topic is solved!