YesNoOk
avatar

How to make my helper's size equal to enemy's? (Read 32988 times)

Started by WastedCoder, July 29, 2022, 10:46:22 pm
Share this topic:
How to make my helper's size equal to enemy's?
#1  July 29, 2022, 10:46:22 pm
  • **
    • Ukraine
My character has a fire attack.
If that attack finishes the enemy, I want him to turn into a barely standing, burning body. I have that animation, but the thing is, the enemy can be Sonic or Broly, which means, they have different sizes. How do I make it so this helper I spawn instead of enemy be the same size. I need it to adjust the size. I tried using const in size parameters of the helper, but it doesn't seem to be working.  :'(

Re: How to make my helper's size equal to enemy's?
#2  July 30, 2022, 01:44:31 am
  • **
A simple fix is to find the scale ratio and apply this scaling factor to the spawned helper's x/y scale. This will give you an approximate height relative to p2.

The y-scale ratio is "EnemyNear,const(size.head.pos.y)" /" Helper's Head pos-y " but for some weird reason, when you just put this in the helper's scale factors mugen rounds it to the nearest integer, which is NOT what you'd want. So instead, store p2's y-pos in a var:

In [Statedef -2], set a fvar for the position of the targets head position,

[State -2, VarSet]
type = VarSet
trigger1 = 1
fvar(14) = EnemyNear,const(size.head.pos.y)   ;--->Using target as a redirect will be better if you have one.
ignorehitpause = 1

Assuming you helper's sprite head position is y=-90 , when you spawn your helper, use:

size.xscale = (fvar(14)/-90)
size.yscale = (fvar(14)/-90)
 

This should work for all standard characters if the y-pos for head is correctly placed in the constants.
For characters that can change sizes with transformations/rounds then, you'd have to code them in separately using author and name triggers.
And as always, you can expand upon the code to make it fit for your needs.


Re: How to make my helper's size equal to enemy's?
#3  July 30, 2022, 10:31:03 am
  • **
    • Ukraine
Thank you! It works perfectly! You really helped me out on this one ^-^

Unless some creators put the wrong data in their characters. But that is not a concern of mine.