homing code (x distance only)

Started by Momotaro, August 07, 2021, 11:42:21 PM

Previous topic - Next topic

Momotaro

Hello,
I would like to know how to code a good homing code based on X distance or xbody distance.
So player will try to reach opponent in x axis.

(basically, something similar to Dictator's head press.)
thanks

NotAGoodName

So, I actually did something like this once.  It's kind of ghetto looking, but I tried to base it on behavior I observed from the original game.  This will, unfortunately, have the effect of making you go backwards if you somehow over-shoot.

[State 300, 1]
type = VelSet
trigger1 = Time = 0
y = -9

[State 300, 1]
type = VelSet
trigger1 = 1
x = (p2dist x) / 25


I just set the Y-velocity once so that the effect looks like a hop.  The X-velocity will then slow down as it approaches the opponent and come to a complete stop when X distance is 0.

Momotaro

Quote from: NotAGoodName on August 08, 2021, 11:44:10 AM
So, I actually did something like this once.  It's kind of ghetto looking, but I tried to base it on behavior I observed from the original game.  This will, unfortunately, have the effect of making you go backwards if you somehow over-shoot.

[State 300, 1]
type = VelSet
trigger1 = Time = 0
y = -9

[State 300, 1]
type = VelSet
trigger1 = 1
x = (p2dist x) / 25


I just set the Y-velocity once so that the effect looks like a hop.  The X-velocity will then slow down as it approaches the opponent and come to a complete stop when X distance is 0.

Oh ! Thanks !
Looks like exactly what I'm looking for!
I will try it!

     Posted: August 24, 2021, 11:32:13 PM
OK, some update, after trying and testing the code.
It works perfectly with some adjustments.

But the cancel version make the move useless...
I mean, If you cancel a normal move with this Special homing move, it will not actually follow P2 since at time 0, P1 is already close to P2.
But as you can see P2 slides back from the normal move hit, and P1 cannot reach P2.



Is there a way to fix it?
How should I update the code?

NotAGoodName

Just from the images, it looks like she has given up the homing velocity too early.  I think you will need to either:

1) Add a special condition when you cancel the attack so that it gets a sort of boost velocity.

or

2) Find a way to maintain to maintain the special velset for a longer duration.  It should definitely still be active during the state in the 3rd image.

Momotaro

Quote from: NotAGoodName on August 25, 2021, 08:49:20 AM
Just from the images, it looks like she has given up the homing velocity too early.  I think you will need to either:

1) Add a special condition when you cancel the attack so that it gets a sort of boost velocity.

or

2) Find a way to maintain to maintain the special velset for a longer duration.  It should definitely still be active during the state in the 3rd image.

THanks a lot for your precious feedback and advices !

Yes, I had "1" in mind actually, but felt it would be a mess with my coding structure.
For "2" I have no idea how to do it.

I got ahead and tried to give a defined velocity depending if the attack hitting is a light, medium or strong one...
IT WORKS.

Warning : the code is a mish mash that would make crying blood to any respectable advanced programer.
But again, it works.

;;STAND
[State 40, ˆÚ"®];EX special version (STAND)------------Pour Y
type = velset
trigger1 = time=0
trigger1 = Statetype != A
y = -8.2;-9.02
;;;;;;x = (p2dist x) / 25;;;;;;;;(homing code - tête chercheuse);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;x = 5.2
;
[State 40, ˆÚ"®];EX special version (STAND)------------Pour X
type = velset
triggerall = prevStateNo != [200, 699];(not combo)
trigger1 = time=0
trigger1 = Statetype != A
x = (p2Bodydist x) / 25;;;;;;;;(homing code - tête chercheuse);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;x = 5.2
;p2Bodydist au lieu de p2dist (pour ne pas viser le milieu du p2)
;
[State 40, ˆÚ"®];EX special version (STAND)------------Pour X
type = velset
triggerall = time=0
triggerall = Statetype != A
trigger1 = prevStateNo = [200, 209];(EN COMBO-light)
trigger2 = prevStateNo = [230, 239];(EN COMBO-light)
trigger3 = prevStateNo = [400, 409];(EN COMBO-light)
trigger4 = prevStateNo = [430, 439];(EN COMBO-light)
x = 0.87;-----TESTO
;p2Bodydist au lieu de p2dist (pour ne pas viser le milieu du p2)
;
[State 40, ˆÚ"®];EX special version (STAND)------------Pour X
type = velset
triggerall = time=0
triggerall = Statetype != A
trigger1 = prevStateNo = [210, 219];(EN COMBO-med)
trigger2 = prevStateNo = [240, 249];(EN COMBO-med)
trigger3 = prevStateNo = [410, 419];(EN COMBO-med)
trigger4 = prevStateNo = [440, 449];(EN COMBO-med)
x = 2.42;-----TESTO
;p2Bodydist au lieu de p2dist (pour ne pas viser le milieu du p2)
;
[State 40, ˆÚ"®];EX special version (STAND)------------Pour X
type = velset
triggerall = time=0
triggerall = Statetype != A
trigger1 = prevStateNo = [220, 229];(EN COMBO-hard)
trigger2 = prevStateNo = [250, 259];(EN COMBO-hard)
trigger3 = prevStateNo = [420, 429];(EN COMBO-hard)
trigger4 = prevStateNo = [450, 459];(EN COMBO-hard)
x = 4.;-----TESTO
;p2Bodydist au lieu de p2dist (pour ne pas viser le milieu du p2)


Whenever I can, I'll choose the effectiveness instead of trying code optimization for weeks.
I only want my character to work. Not to take a decade to be completed.

NotAGoodName

If it works, it works.  No shame in functionality.

I will say that the reason you're not getting the same results is because of the usage of time as a trigger.

[State 40, ˆÚ"®] ;simplified
type = velset
trigger1 = time=0
x = (p2Bodydist x) / 25


In this case, you only have a velocity when time is exactly 0.  This means that you get a nice amount of velocity which depends on your distance to the opponent, but as soon as "time > 0", you only have the velocity that you were left with.

This velocity code can (is intended to) work for a much longer duration because you will automatically slow down as you approach the opponent.  That is what makes it homing.  So really, you can use something like "time < 2" (or more) and you should get the boost you need.

Of course, you can do whatever you thinks works and looks best.  This isn't a criticism.

Momotaro

Quote from: NotAGoodName on August 25, 2021, 10:32:41 AM
If it works, it works.  No shame in functionality.

I will say that the reason you're not getting the same results is because of the usage of time as a trigger.

[State 40, ˆÚ"®] ;simplified
type = velset
trigger1 = time=0
x = (p2Bodydist x) / 25


In this case, you only have a velocity when time is exactly 0.  This means that you get a nice amount of velocity which depends on your distance to the opponent, but as soon as "time > 0", you only have the velocity that you were left with.

This velocity code can (is intended to) work for a much longer duration because you will automatically slow down as you approach the opponent.  That is what makes it homing.  So really, you can use something like "time < 2" (or more) and you should get the boost you need.

Of course, you can do whatever you thinks works and looks best.  This isn't a criticism.

Absolutely no problem with this. (I know my code is pretty noobish)

You're right, I tested your method and it's sucessful.

Actually, I already updated airbone version of this move with my "garbage" code. and since it work, I will keep it.

But thanks again, for giving me some very good advices! and for your support!