loopier / animatron

Animatron for Godot 4.x <
15 stars 1 forks source link

Something broke `/scale` #59

Closed loopier closed 2 weeks ago

loopier commented 2 weeks ago

/scale is not working as expected. It has very weird behaviour. It throws an error which shouldn't be there:

Property not found: AnimationPlayer:<AnimationPlayer#373611825366>.scale

Could it have something to do with the masking re-parenting hierarchies?

loopier commented 2 weeks ago

Some examples:

b is scaled down only when /size b 1 is executed. It's should only be rescaled when the parent is rescaled.

/create a square
/create b square
/move/x b 500
/size a 0.25
/parent b a

/size b 1

b is not scaled using wildcard:

/create a square
/create b square
/move/x b 500
/size * 0.5
totalgee commented 2 weeks ago

Regarding your first example of "broken" behaviour. For me, it is working correctly (or at least, as I would expect):

/load cog

/create a cog
/create b cog
/move/x b 400
/size a 0.25
/parent b a
# At this point, the parent 'a' is scaled 0.25x, and the child 'b' (which was full-size)
# is still "globally" at its original size, but now it's a child of 'a'. That means its local scale
# was compensated by the parenting operation, so the local scale is now actually 4x.
# So, when you call this:

/size b 1
# then it "shrinks" down to be the same size as its parent (its scale is 1x the parent).
# If you want it to scale it relative to its current size, you should use /scale, which will
# multiply its current scale instead.

/scale b 1
# The above is a no-op, whatever scale the actor is.

# If you actually want to set its global scale back to "original size", you could use this
# (you can make a def for it)

/property /global_scale b 1 1
# After calling this, 'b' will have its original 100% scale, regardless of any parents and
# their scales.
loopier commented 2 weeks ago

Aha, now I see what confuses me, it took me quite a while to figure out what's de difference between these two examples:

/load square

# example 1
/create a square
/create b square
/size * 0.25
/move/x b 500
/parent b a

# example 2
/clear *
/create a square
/create b square
/size a 0.25
/move/x b 500
/parent b a

On the first example, /size is set with a whildcard. It doesn't apply to all actors, and it renders a different result than setting it to a specific actor.

When changing the * by a ? in the first example it works as expected.

loopier commented 2 weeks ago

I commited the fix in d32c3beafdc9a34fae42bdc6b6435cbd6f262cc0 .

I had to change the recursivity boolean to false in the find_children method when getting actors by name. But this broke accessibility to children, preventing even to unparent them. So I had to change it back to true in 8bb0ad14e355c8148768b81b26cec707ed865a90.

The * wildcard is not working when used by itself (without complementing other characters).

/load square
/create a1 square
/create a2 square
/rotate a1 15 # rotates a1, as expected
/rotate a* 15 # rotates both a1 and a2 as expected
/rotate * 15 # rotates only a1, it should rotate both a1 and a2

I'm not sure how to fix this.

totalgee commented 2 weeks ago

This should all be fixed now (partly confusion, partly '*' wildcard not working properly). Any further issues, we can open a new issue.