YesNoOk
avatar

Changing width based on scale constant (Read 1802 times)

Started by SaltAddict, October 23, 2021, 04:23:28 PM
Share this topic:
Changing width based on scale constant
#1  October 23, 2021, 04:23:28 PM
  • avatar
  • ***
    • Portugal
I'm trying to set it so that my character's width value is automatically changed based on the value of the xscale constant. This is to make it easier for the user to resize the character if needed, since his sprites are bigger than normal. However, my code is giving me bonkers results:

Code:
[state -2 change width based on sprite scale] 
type = width
trigger1 = 1
value = floor(29*const(size.xscale)), floor(25*const(size.xscale))
ignorehitpause = 1

29 and 25 are the original width values, which fit perfectly with the full sized sprites. For some reason this code makes the width line HUGE, way wider than the character, even though I've set the xscale to 0.85.  Even if I set the xscale to 1 (so, no multiplication, in theory), the width line is still massive.
I'm not good at maths so there might be something obvious I'm missing here? I've tried it with ceil instead, and without floor nor ceil; I've also tried const(size.ground.front)*(const.size.xscale), but it gives me the same result.
Re: Changing width based on scale constant
#2  October 24, 2021, 12:08:36 AM
  • *****
  • Shame on you!
    • USA
With my Samus I use
; fvar 14 = Const(size.xscale) ;used for positioning projectiles
to keep track of the scale. You're going to run into a TON of problems if you try to use size.xscale/yscale to do the math.

Some examples:
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty

This is how I have my width set up

[State 0, Width]
type = Width
trigger1 = anim = [1000,1002]
trigger1 = (AnimElemTime (2) >= 0) && (AnimElemTime (18) < 0)
edge = floor(290*fvar(14)),0;45
vVv Mauru Mauru Released vVv
Last Edit: October 24, 2021, 12:11:51 AM by Odb718
Re: Changing width based on scale constant
#3  October 24, 2021, 01:35:07 PM
  • avatar
  • ***
    • Portugal
With my Samus I use
; fvar 14 = Const(size.xscale) ;used for positioning projectiles
to keep track of the scale. You're going to run into a TON of problems if you try to use size.xscale/yscale to do the math.

Some examples:
Spoiler, click to toggle visibilty
Spoiler, click to toggle visibilty

This is how I have my width set up

[State 0, Width]
type = Width
trigger1 = anim = [1000,1002]
trigger1 = (AnimElemTime (2) >= 0) && (AnimElemTime (18) < 0)
edge = floor(290*fvar(14)),0;45

Same problem. I set fvar(14) to 0.85, the width bar still becomes huge.

EDIT: Ok, this is really weird, it seems like the width from the controller gets added to the character's regular width? But here: https://mugenguild.com/forum/topics/width-sctrl-170306.0.html it says the controller sets the width, not adds to it?
Last Edit: October 24, 2021, 01:40:14 PM by SaltAddict