[Coding] Explod facing

Started by Redash, May 29, 2018, 05:32:20 PM

Previous topic - Next topic

Redash

Hi,

I wonder if anyone has any idea what is the correct Condition code to determine if a projectile lands in front or behind of enemy char?
My goal is the a "horizontal turn" (aka change of facing) of the Explod anim depending it lands behind or in front of the enemy

I tried the below but the facing is NOT always right when the chars switch facing/side...

;(IMPT: This is a Helper-Type Projectile state, Pos X refers to the position of the Helper-Type Projectile, not player character)
[State 1000, Explod]
type   = Explod
trigger1   = (MoveContact = 1) || (MoveHit = 1) || (MoveGuarded = 1)
trigger2   = (Pos Y >= -20)
anim   = 1000
;id   = 2300
pos   = 0,0
postype   = p1
facing   = Cond(Enemy,Pos X > Pos X, -1, 1) <= this is the part I have trouble with
;vfacing   = 1
bindtime   = 0
;vel   = 0,0
;accel   = 0,0
;random   = 0,0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale   = 1,1
sprpriority = 3
;ontop   = 0
;under   = 0
shadow   = 0,0,0
ownpal   = 1
removeongethit = 1
ignorehitpause = 1
;trans   =
persistent = 0
;supermove =

I had also tried
facing = 1 && (Enemy,Pos X > Pos X)
(Enemy,Pos X > Pos X) * Cond((Pos X > Enemy, Pos X) && (Enemy, Pos X > Root, Pos X), -1, 1)
among many others...

But all not working properly when the characters are standing at certain distance or spots... Help please...

XGargoyle

Use P2Dist or P2BodyDist

QuoteFor comparing the X-distance, P2Dist gives the X-distance of P2's axis from P1's axis. A positive value indicates P2 is in front of P1. See also P2BodyDist.
http://mugenguild.com/forum/topics/p2dist-triggers-169013.0.html


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!

Redash

Thanks XGargoyle.

Its so straightforward with a P2Dist  < 0.

Appreciate the help. Saved me lots of agony.