Go.animate on sprite and game object

Wasted a whole afternoon on this one but it doesn’t work. Am I missing something?

I want to do a simple “breathing” animation on each of my player sprites. I created a game object and assigned it a sprite and script component. On init() I start an endless animation loop which deforms #sprite's scale property.

^What I get is this^ - It scales the sprite from the center point. I need the motion to happen from the center_x and bottom_y (the feet). My idea was to shift its position.y on each update() by the amount at that the sprite was scaled. Please see my code…

The debug does seem to return valid data which would proof that the calculations are correct (or do I miss the forest for the trees)? Anyway, given that the output is correct, why is it not translating right and why is it jumping instead of smoothly lerp-ing? I tried to do this with vmath.lerp but same result.

# PS: Here is what the prefab for that GO looks like

Don’t you need to offset the sprite (like you did) and then animate the game object’s scale and not the sprite?

Hello @jack0088

I think your pivot is not middle bottom . you should use position 0,4,0 to achieve it. You may not need shift y position.

Best Regards,

I think that doesn’t matter, the outcome should be the same. But you can’t scale game objects with uneven x and y. You can only make a uniform scale. (at least this is what the docs say for go.set and go.animate)

# EDIT: I did it the other way around, see post below, pls!

@ArmandCloud GO’s can’t be scaled non-uniform, that’s why I need to scale the sprite component directly. Therefore repositioning it inside its parent does not have any effect, as the scaling performs from the sprite’s center anyway, regardless of sprite’s parent.

The hero.go is moved by a camera. That’s why I can’t set its position directly, but have to recalculate and add the “breath”-offset each frame…