Problems with TargetBind

Started by Dawn de Era, November 27, 2016, 07:17:20 PM

Previous topic - Next topic

Dawn de Era

I can't seem to get this to work correctly when facing left.

What goes wrong: https://streamable.com/l8y7

Helper Code: http://pastebin.com/Sa6zgvhc

It's been bugging me for a while, now.

EDIT: The problem is solved! Thanks to altoiddealer (love your work), Odb718 (you sure know your stuff), and Niitris (you made the largest leap forward in this code by far)!

Dawn de Era

If it wasn't made clear, I'm trying to get the attack to behave the same on both sides. But, as you can see, the left has some odd behavior from the TargetBind movement.

altoiddealer


[State 3001, BindToRoot]
type = BindToRoot
trigger1 = Time <= 0
time = 1
pos = 35,-52


How about just use pos=35,-52 in your Helper state controller? :P

I recommend using absolute values to abolish the need for facing.

P2 just goes straight up, right?  So Pos X value should just be "target,Pos X" (NO X MOVEMENT)

And for the Pos Y, Player 1's will always be "0" as the pencil is standing.  So it's just target,Pos Y - 1

Time%1 = 0 is always true.


[State 3002, TargetBind]
type = TargetBind
triggerall = NumTarget
triggerall = abs(target, pos x - parent,pos x) < 74
trigger1 = Time%6 = 0
time = 1
pos=target,Pos X,target,Pos Y-1

[State 3002, TargetBind]
type = TargetBind
triggerall = NumTarget
triggerall = abs(target, pos x - parent,pos x) = [74,184]
trigger1 = Time%5 = 0
time = 1
pos=target,Pos X,target,Pos Y-1

[State 3002, TargetBind]
type = TargetBind
triggerall = NumTarget
triggerall = abs(target, pos x - parent,pos x) > 184
time = 1
pos=target,Pos X,target,Pos Y-1


No guarantees but I think this will work.  If not, adjust ti a bit.  But you should be able to abolish the duplicate controller for facing using abs()


Dawn de Era

Is there possibly a way to more easily adjust the rate the opponent goes up by relative to the distance from Pencil? So that it aligns with the rotation.

altoiddealer

#4
Just do some math :P

abs(target, pos x - parent,pos x) - that's the X distance.  So this can be factored into the Y pos.

Since the rate is constant (P2 will not accelerate), the value can just be multiplied by a fraction.

[State 3002, TargetBind]
type = TargetBind
triggerall = NumTarget
time = 1
pos = target,Pos X , Floor(target,Pos Y-(abs(target, pos x - parent,pos x)*.013))


If it doesn't work at all, you may need to convert the X dist part to a float to do the math. (multiply it by 1.0)

[State 3002, TargetBind]
type = TargetBind
triggerall = NumTarget
time = 1
pos = target,Pos X , Floor((target,Pos Y*1.0)-(abs(target, pos x - parent,pos x)*.013))


Adjust the .013 and you should find something that works.


Dawn de Era

One last thing, does that work when Pencil is facing either side? This is crucial, seeing as that was the reason this bug appeared in the first place.

Dawn de Era

#6
First one broke the attack severely.
Edit: Second one gives the same result.
Edit 2: TL;DR, the opponent goes completely bonkers.
Problem: https://streamable.com/xshz
Helper Code: http://pastebin.com/r1SQiVRa

altoiddealer

Try adjusting that fraction .013    I think I just miscalculated.  But the logic should be true.

Do like .003 and see what happens   There should be a value that works perfectly

This code should work the same regardless of facing


Dawn de Era

I tried .003, same result.
I even tried ridiculous variables like .0000000006 and .0000000000000000001, same result.
I also tried .3, again, same result, but worse in the case of the camera moving back and forth.

altoiddealer

Hmmm... maybe try changing the 1.0 to 1.000
And try the original number .013

Honestly I'm not sure what's up because as far as I can tell the math checks out

I think I got the X value wrong, too. Should probably be:  abs(target,Pos X - parent,Pos x)


Dawn de Era

Tried both the original and the fixed x with 0.13, same result, but with no screen-shaking.
Tried the fixed with 0.0003, the screen-shaking returns.

altoiddealer

Try this and let me know if it's any better

[State 3002, TargetBind]
type = TargetBind
triggerall = NumTarget
trigger1 = 1
time = 1
pos = abs(target,Pos X - parent,Pos x) , Floor((target,Pos Y*1.000)-(abs(target, pos x - parent,pos x)*.001))


Dawn de Era

The result? The same thing, except now, the player is shot backwards.
No offense, but are you actually testing these?

altoiddealer

Nope.

I'm trying to help, though.

So, again I was wrong... about the Pos Y.  I'm pretty confident with this one.

[State 3002, TargetBind]
type = TargetBind
triggerall = NumTarget
trigger1 = 1
time = 1
pos = abs(target,Pos X - Pos x) , Floor(((target,Pos Y-Pos Y)*1.000)-(abs(target, pos x - pos x)*.013))

NOW you probably just need to adjust the .013 part slightly


Odb718

Quote from: HarmoknightYo on November 30, 2016, 12:24:17 AMNo offense, but are you actually testing these?
Lol that's your job.

Just jumping into this thread,
abs(target,Pos X - Pos x) , Floor(((target,Pos Y-Pos Y)*1.000)-(abs(target, pos x - pos x)*.013))
This makes me think that you have an FX/Helper in between P1 & P2 in the middle of them, and it kinda raises up depending on the 2 character's overall distances.
So say P2's pos y is -54, and Pos X is 7.
P1's pos x is 139.
then
pos = abs(7 - 139) , Floor(((-54-0)*1.000)-(abs(7 - 139)*.013))
pos = 132, -52
132*.013 is going to be 1.whatever. This fraction is tiny. It'll almost always be 0 to 2. So why have it? It'll get up to max value of 5 I'd imagine.
abs(-132) is pretty far from 132 also. Does this code work right? I am half asleep so I may be getting my values confused but once you're on the other side of the middle of the stage it goes negative right? You'd only ever get the effect on the left side??

What scale do you want to adjust the effect at? Like how far apart should it be at it's max height, What IS that height? When P1 & P2 are as close as possible, what height should the effect be at?? That will determine your range. Then we can figure out the equation that solves that range with the values we can read.

Also, Set up a debug variable that you can watch these values just for testing.
Use a parent/varset in the state and read it with displaytoclipboard and see what values it's pumping out. You should be able to adjust your equation pretty easy.

Just go back to
Floor(((target,Pos Y-Pos Y)*1.000)-(abs(target, pos x - pos x)*.013))
and think, when they're super close I want the height to be say, -6
and when they're like 400 away, I need the height to be -95
well,
-6=((0-0)*1.00)-(32-10)*x
and solve for x.
Then do it for
-95=((-21-0)*1.00)-(232--110)*x
vVv Gouken718 vVv SabreTooth718 vVv


altoiddealer

The TargetBind controller is executed by a helper, which is spawned at a +X and -Y distance away from the parent Player.

The animation is a beam that rotates upwards.  The closer the enemy is to the player, the slower he should "lift up" off the ground (to follow the anim).

The target remains at a fixed X distance throughout


Niitris

I might be missing something, but isn't target, Pos X-Pos X just a fancy way of saying zero? :S

If that's the case, just use zero for the TargetBind's X value on both sides.

altoiddealer

The target's Pos X is not equal to the helper's Pos X, so subtracting them does not equal zero :P


Niitris

But it's not subtracting from the helper, that would be (target, Pos X) - Pos X

The entire equation is part of the redirect since there's no parenthesis separating the two integers.

Odb718

Subtracting from the helper would be Pos x - target,Pos x
I think. Usually Mugen is good at knowing Parent, Target, and the like automatically do (parent, vel x)-var(11) or whatever.
That's kinda why I recommended using debug to watch those values. Some times with specials/hypers I'd slow the animation down just to watch it longer. Then speed it back up when it works.
vVv Gouken718 vVv SabreTooth718 vVv