News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

coding a wall jump?

Started by LameLikeMike, July 19, 2008, 10:39:10 PM

Previous topic - Next topic

LameLikeMike

Ok, I'm not coding a traditional fighting game wall jump, but one more like the megaman x series.

my problem is this:

currently the character can cling to the wall, and slide down fine.  when he hits the ground he goes back to state 0, and if you let go of the direction towards the wall he changes into state 50.

but what i need is a way to make the character only change to state 50 if the direction towards the wall is let go for more than a certain amount of time, we'll say 10 game ticks, regardless of how long he has been in the wall cling state so that jump commands have time to be made before changing the state.  is this possible?

here is the state in question for reference
*note
-that the character has autoturn off, and automatically turns when back, or holdback is pressed except in [State 61]
-dashing and jumping are button controlled
-[State 53] is a state exactly like 50, but used after dashes, so that you can't air dash twice or air dash after dash jumping.

;Wall Cling/Slide
;---------------------------------------------------------------------------
[StateDef 61]
type = A
movetype = I
physics = A
anim = 61
ctrl = 0

[State 61, VelMul]
type = VelMul
trigger1 = 1
trigger1 = Pos Y < -50
trigger1 = Vel Y < 0
x = 1
y = .75

[State 61, VelSet]
type = VelSet
triggerall = Pos Y < 0
triggerall = FrontEdgeBodyDist <= 0
triggerall = Command = "holdfwd"
triggerall = Vel Y > 0
trigger1 = PrevStateNo = 50
trigger2 = PrevStateNo = 53
x = 0
y = 2

[State 61, Floor]
type = ChangeState
trigger1 = Pos Y = 0
value = 0

[State 61, Let Go]
type = ChangeState
trigger1 = Command != "holdfwd"
value = 50
ctrl = 1

[State 61,Jump up Wall]
type = ChangeState
triggerall = Pos Y > -150
triggerall = Pos Y < 0
trigger1 = Command = "y"
trigger1 = Command = "holdfwd"
value = 42

[State 61, Jump Away]
type = ChangeState
triggerall = Pos Y > -150
triggerall = Pos Y < 0
trigger1 = Command = "y"
trigger1 = Command = "holdback"
trigger1 = Command != "hold_x"
value = 43

[State 61, Dash Jump Away]
type = ChangeState
triggerall = Pos Y > -150
triggerall = Pos Y < 0
trigger1 = Command = "holdback"
trigger1 = Command = "hold_x"
trigger1 = Command = "y"
value = 44

also if there is a better way to code this type of "megaman x wall slide" you can tell me that too.

PotS

Quote from: LameLikeMike on July 19, 2008, 10:39:10 PM
but what i need is a way to make the character only change to state 50 if the direction towards the wall is let go for more than a certain amount of time, we'll say 10 game ticks, regardless of how long he has been in the wall cling state so that jump commands have time to be made before changing the state.  is this possible?
Make a variable that adds up by 1 when the player isn't holding the right direction, then trigger the changestate to 50 if that var is greater than 10 (or whatever you like).
Also don't forget to set the var to 0 at the beginning of the state and when the player is holding the right direction.
You can help with Ikemen GO's development by trying out the latest development build and reporting any bugs on GitHub.
My Mugen and Ikemen content can also be found here.

LameLikeMike

thanks your a life saver, i never really understood how variables worked, but i thought i might be able to use them, everything is working fine now, thanks again

LameLikeMike

#3
actually now that i tested it more  i have a problem, it is giving me time to do my command now but it still won't exit the state i just go back to a regular falling velocity but stay against the wall, in state 61 ???

heres what i added
[State 61, VarSet]
type = VarSet
trigger1 = Time >= 0
trigger1 = Command = "holdfwd"
sysvar(1) = 0

[State 61, VarAdd]
type = VarAdd
trigger1 = Time = 1
trigger1 = Command != "holdfwd"
v = sysvar(1)
value = 1

[State 61, Let Go]
type = ChangeState
triggerall = Command != "holdfwd"
trigger1 = sysvar(1) >= 5
value = 50


i guess i still don't get variables




PotS

It happens because your triggers for increasing the var only work at Time=1, that's one single tick, so it'll never reach anything higher than 1. Try without that trigger.

Also the triggers for that first Sctrl should be:
trigger1 = Time = 0; Resets var at beginning of the state
trigger2 = Command = "holdfwd"; Resets var if holding correct direction

And don't use sysvar(1), it's a system variable reserved for the common1.cns states, use something like var(1).
You can help with Ikemen GO's development by trying out the latest development build and reporting any bugs on GitHub.
My Mugen and Ikemen content can also be found here.

LameLikeMike

#5
Ok i still have a problem.

Now when I let go of the direction towards the wall, he falls fine,  when i do the jump commands, they also work as planned, but when i hold away from the wall, my character falls but doesn't turn around as he should, and therefore has no air movement control, as it is triggered by command = "holdfwd" in State 50.   I'll post all the current relavent code, and a vid to clarify.

wall cling
;Wall Cling/Slide
;---------------------------------------------------------------------------

[StateDef 61]
type = A
physics = A
anim = 61
ctrl = 0

[State 61, VarSet]
type = VarSet
trigger1 = Time = 0
trigger2 = Command = "holdfwd"
v = 1
value = 0


[State 61, VarAdd]
type = VarAdd
trigger1 = Command != "holdfwd"
v = 1
value = 1

[State 61, Let Go]
type = ChangeState
trigger1 = var(1) >= 10
value = 50


[State 61, VelMul]
type = VelMul
trigger1 = 1
trigger1 = Pos Y < -50
trigger1 = Vel Y < 0
x = 1
y = .75


[State 61, VelSet]
type = VelSet
triggerall = Command = "holdfwd"
trigger1 = Vel Y > 0
x = 0
y = 1.5


[State 61, Floor]
type = ChangeState
trigger1 = Pos Y = 0
value = 0



[State 61,Jump up Wall]
type = ChangeState
triggerall = Pos Y > -150
triggerall = Pos Y < 0
trigger1 = Command = "y"
trigger1 = Command = "holdfwd"
value = 42

[State 61, Jump Away]
type = ChangeState
triggerall = Pos Y > -150
triggerall = Pos Y < 0
trigger1 = Command = "y"
trigger1 = Command = "holdback"
trigger1 = Command != "hold_x"
value = 43

[State 61,Dash Jump Away]
type = ChangeState
triggerall = Pos Y > -150
triggerall = Pos Y < 0
trigger1 = Command = "holdback"
trigger1 = Command = "hold_x"
trigger1 = Command = "y"
value = 44


My barely modified State 50
; Jump Up
[Statedef 50]
type    = A
physics = A

[State 50, change direction]
type = VelSet
triggerall = Vel X <= 0
trigger1 = Command = "holdfwd"
trigger2 = Command = "holdback"
x = 4

[State 50, 1]
type = VarSet
trigger1 = Time = 0
sysvar(1) = 0

[State 50, 2]
type = ChangeAnim
trigger1 = Time = 0
value = ifelse((vel x)=0, 41, ifelse((vel x)>0, 42, 43))

[State 50, 3]
type = ChangeAnim
trigger1 = Vel y > -2
trigger1 = SelfAnimExist(anim + 3)
persistent = 0
value = Anim + 3


Turn/no autoturn

[State -2, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noautoturn

[State -2, Turn]
type = Turn
triggerall = Command = "back"
triggerall = Command = "holdback"
trigger1 = Stateno != 61
trigger2 = Vel X <0


for visual reference, here is the vid.
*note that the sprite for the wall cling, makes the character appear to face away from the wall but is telling mugen that he is facing the wall

http://www.youtube.com/watch?v=L-1KOxDmN9o

PotS

Quote from: LameLikeMike on July 21, 2008, 12:31:32 AM
[State -2, Turn]
type = Turn
triggerall = Command = "back"
triggerall = Command = "holdback"
trigger1 = Stateno != 61
trigger2 = Vel X <0
Try without that first triggerall.
You can help with Ikemen GO's development by trying out the latest development build and reporting any bugs on GitHub.
My Mugen and Ikemen content can also be found here.

LameLikeMike

thanks but that actually made it worse, the character won't turn on the ground when i do that,    i have a couple things i'm gonna try, but if you think of anything else, advise will be gladly taken