YesNoOk
avatar

Scaling Explod Helper Relative to Parent's Distance (Read 6978 times)

Started by Fighting Toys Freak, April 29, 2017, 11:46:25 pm
Share this topic:
Scaling Explod Helper Relative to Parent's Distance
#1  April 29, 2017, 11:46:25 pm
  • **
  • New changes, new me!
Hey all.

I am attempting to enlarge a helper's width relative to its player's distance. However, the following code does not execute the phenomenon that I had planned:

Code:
[State 1640, X]
Type = VarSet
Trigger1 = 1
fvar(0) = (Parent, Pos X - Pos X) * Facing ;Adjust the direction towards player facing

;Finds the Y component of the vector Player, EnemyNear
[State 1640, Y]
Type = VarSet
trigger1 = 1
fvar(1) = (Parent, pos Y - Pos Y)

;Finds the vector length
;Formula of the length of a given vector AB
;|AB| = (AB(x)^2 + AB(y)^2)^1/2
[State 1640, Vector Length]
Type = VarSet
trigger1 = 1
fvar(2) = Atan(fvar(1)/fvar(0))*-270/Pi

[State 0, AngleSet]
type = AngleSet
trigger1 = 1
value = fvar(2)

[State 0, AngleDraw]
type = AngleDraw
trigger1 = 1
scale = abs(ParentDist X/133),1
ignorehitpause = 1

[State 0, Offset]
type = Offset
trigger1 = ParentDist X != 0
x = abs(ParentDist X/133)*(pos x)*facing
ignorehitpause = 1

In addition, I am attempting to offset the helper's position as the helper enlarges.

What could be wrong with the code?
Re: Scaling Explod Helper Relative to Parent's Distance
#2  April 30, 2017, 12:03:47 am
  • *****
  • Shame on you!
    • USA
Try AngleDraw above AngleSet. Sounds dumb but somethings are picky in Mugen.
Have you tried using set numbers to see if they actually activate? Set them to some random number and see.
Read through http://mugenguild.com/forum/topics/angledraw-sctrj-169975.0.html
and the rest of the "Angles" for clues on why it's not working.
vVv Ryuko718 Updated 10/31/22 vVv
Re: Scaling Explod Helper Relative to Parent's Distance
#3  April 30, 2017, 06:54:46 pm
  • **
  • New changes, new me!
It seems that I need to clarify the issue of the matter: I am not implying that the execution is not functioning; I meant to state that the execution is not what I intended to happen. The helper elongates too far across the screen, and its position does not restore to its original position as a consequence of the AngleDraw controller's scale parameter.

Perhaps, the algorithm of the AngleDraw controller's scale parameter or algorithm of the Offset controller is incorrect. Or maybe both. The following code could be the underlying issue:
Code:
;Finds the X component of the vector Player, EnemyNear
;Formula to find the components of a given vector AB
;V(x) = B(x) - A(x)
;V(y) = B(y) - A(y)
[State 1640, X]
Type = VarSet
Trigger1 = 1
fvar(0) = ParentDist X * Facing ;Adjust the direction towards player facing

;Finds the Y component of the vector Player, EnemyNear
[State 1640, Y]
Type = VarSet
trigger1 = 1
fvar(1) = ParentDist Y

;Finds the vector length
;Formula of the length of a given vector AB
;|AB| = (AB(x)^2 + AB(y)^2)^1/2
[State 1640, Vector Length]
Type = VarSet
trigger1 = 1
trigger1 = fvar(0) > 0
fvar(2) = Atan(fvar(1)/fvar(0))*-270/Pi

[State 0, AngleDraw]
type = AngleDraw
trigger1 = 1
scale = abs(ParentDist X/133),1
ignorehitpause = 1

[State 0, AngleSet]
type = AngleSet
trigger1 = 1
value = fvar(2)

[State 0, Offset]
type = Offset
trigger1 = ParentDist X != 0
x = abs(ParentDist X/133)
ignorehitpause = 1
 

What could be wrong with the algorithm(s)?
Last Edit: May 03, 2017, 09:26:13 pm by Fighting Toys Freak
Re: Scaling Explod Helper Relative to Parent's Distance
#4  May 01, 2017, 01:16:58 am
  • *****
  • Shame on you!
    • USA
How'd you come up with your 133 value?
You have
scale = abs(ParentDist X/133),1
but have you tried adjusting that value to get something closer to what you want?

The way I'd figure it out is, at the max distance this thing can get away from P1 how much bigger should it get?
So if P1's standing with his back to the left wall, can it get to the right side of the screen? If so, how big should it be? 3x as large? 15x?

Then, at it's closest, should it still be 1x? or should it get smaller?
Right now you have it once it's 133 pixels away it'll be 100% of it's normal size. at 120 it'll be around 90% of it's size. at 266 it'll be 200%. Is this what you're seeing on screen?

On top of that, say you want it to grow 7.5x as big at it's maximum, but at half the distance to the right side of the screen. Once it hits, say 300 pixels away it should stop growing.

Does the helper go up in the air? It seems like it, but you dont adjust the scale based off of fvar(2). I'd think you'd want the scale to change based on the radius and not just the X distance. Like if it's 200 pixels in the air, 10 pixels out, should it be the same size as it right next to P1?
vVv Ryuko718 Updated 10/31/22 vVv
Re: Scaling Explod Helper Relative to Parent's Distance
#5  May 01, 2017, 04:15:49 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
In which directions can the helper move?  Just left/right?  Can it move up AND down from where it is spawned?

For starters, you can just change the helper's axis position so you don't need OffSet.  For instance if it can only move left/right/up, then you could align the axis in the bottom left corner, and it will scale/pivot from that point - no need to offset the animation.

As ODB said, you're scaling code does not factor Y distance at all.


If this helper can only move left/right, then the coding can be simplified a lot.

Re: Scaling Explod Helper Relative to Parent's Distance
#6  May 03, 2017, 09:49:43 pm
  • **
  • New changes, new me!
I intend for the helper to shift, or move, to the same position that has been set prior to its elongation. In other words, it is supposed to return to the same position that it was originally so as to correct the displacement of the helper's animation while the animation elongates. This is the intended purpose of the Offset controller. I have tried binding the helper in respect to the player's position, however to no avail.

I have not figured out on how I should factor in the float variable whose expression is supposed to compute a numerical angle.

It seems that I need to clarify the purpose of the value of 133: the reason why the value, 133, is in the denominator of the expression is that the width of the animation changes as the distance of the parent increases in respect to the width of the animation. Therefore, the animation should elongate based on the distance of the parent from its helper and offset the new position to its original according to the width of the animation.

The expression alongside the parameters of the Offset and AngleDraw controllers seems to be the main issue.

How should I change the expression to account for the distance of the parent and the angle of the helper?

I hope the information satisfies your questions, altoiddealer and odb718.   
Last Edit: May 04, 2017, 01:30:23 am by Fighting Toys Freak
Re: Scaling Explod Helper Relative to Parent's Distance
#7  May 03, 2017, 11:00:24 pm
  • *****
  • Shame on you!
    • USA
You never just answer the questions. We both asked if it can travel vertically. There's no concise answer to that question. But we can surmise it can by the use of angles.

I fully understand the effect you're trying to accomplish. What I am telling you is that you want an equation, not a whole number there.
Is 133 the actual width of your sprite or something? Why did you choose 133 as the denominator?
vVv Ryuko718 Updated 10/31/22 vVv
Re: Scaling Explod Helper Relative to Parent's Distance
#8  May 04, 2017, 01:56:50 am
  • **
  • New changes, new me!
You never just answer the questions. We both asked if it can travel vertically. There's no concise answer to that question. But we can surmise it can by the use of angles.

I fully understand the effect you're trying to accomplish. What I am telling you is that you want an equation, not a whole number there.
Is 133 the actual width of your sprite or something? Why did you choose 133 as the denominator?

The value, 133, is the actual width of the sprite. I am trying to have the sprite stretch horizontally and not travel toward any direction. In addition, I am aiming for the helper's sprite to rotate at an angle whenever the parent travels vertically.

For instance, suppose that the helper's parent travels toward a distance of 266 from the helper along the x-axis and that the helper's position along the x-axis is 56. The helper as a result stretches to double of its width. The position at where the end of the helper's sprite will displace from where it was originally called. Some equation in the offset parameter along the x-axis will then be prompted to correct the displacement of the end of the sprite back to its original position.

In a different yet another instance, suppose that the helper's parent travels down at distance of 266 below the helper along the y-axis and at a distance of 266 along the x-axis. The same case as before will apply to the helper's sprite expanding across the x-axis.  However, the sprite rotates at angle toward the position at which the parent is along the y-axis. This is when the AngleDraw controller will be called to rotate the sprite so that it corresponds to the resultant of the parent's velocity/distance.

Therefore, how would I formulate an equation for the parameters of both the AngleDraw and Offset controllers while satisfying both instances?

I hope this information suffices.
Re: Scaling Explod Helper Relative to Parent's Distance
#9  May 04, 2017, 09:10:22 am
  • *****
  • Shame on you!
    • USA
56/133 != 2. Which is what you say you want.
Pythagoras' theorem is what you'll use to translate X and Y distance into total distance. We'll suppose you make it var(718).

"For instance, suppose that the helper's parent" <<<I imagine this is P1? Or is a helper spawning a second helper for the sprite?

First thing I'd suggest is just drop the offset code all together. Think about it like this. When you get to 56 pixels away, you want it to be a certain size. Then you want to offset it so the center is where it'd look correct at right?
So say it's 56+14. Well that's 70. So the size for spot 56 should just be the size for 70. Make mugen do the correct size for you where ever it lands at. Like if the position was 44, and the offset was 12. THAT'S 56. So the scale for your 44 would just be that at position 56. I'd drop the needless math.

But back to the math you want.
At 56 pixels away, you want it 2x the width. (Var(718)/28)
At 112 pixels away, do you want it 3x as big or 4x as big?  (1+(var(718)/56))  OR  (Var(718)/28) 

 (1+(var(718)/56)) would have it so at 0 pixels away it's still 100% of it's normal size.


If the offset is being done because the center of the image is off, Center the animation.
vVv Ryuko718 Updated 10/31/22 vVv