0
\$\begingroup\$

I have a sprite that is inside a triangular like shape. How to make the sprite decrease in size as it moves down the shape?

https://ibb.co/gjc6oS

\$\endgroup\$
  • \$\begingroup\$ Does the sprite move freely on the scene, or is it always attached to the triangular shape? \$\endgroup\$ – Leo Mar 7 '18 at 11:47
1
\$\begingroup\$

If I remember sprites in Unity have a variable local scale. You just have to apply the intercept theorem on the scale.
Basically: (oldScale.y/oldDistanceToPivotpoint) = (newScale.y/newDistanceToPivotpoint)
Same works for scale.x.
You can do this every frame.
Your distanceToPivotpoint is simply the distance from the center of your sprite to the lower corner of your triangle.

\$\endgroup\$
0
\$\begingroup\$

One technique that you could try is the following: When you move the sprite downwards within the triangle, you could decrement the sprites lower width, then it's upper width, gradually; ultimately creating that sucking in effect of the sprite moving through that shape.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.