let me try to explain, I want to put a spell in my game like this one: http://img02.deviantart.net/b7db/i/2012/310/2/d/pixel_goku_alt_kamehameha_by_eternityunknown-d5k8d20.png
its 3 sprites, one is easy, just stays near the hand of the character so let’s disregard this one. The body of the spell scales as the spell progresses and the tip moves when the body scales. The problem is that it can be cast in 360 degrees.
so, I created a gameobject as parent, put the body and the tip as children, put the body pivot to the left, rotate the parent, scale the body it and its perfect , works as intended. but then I have to calculate on update where the tip of the spell has to be each frame and It has been a pain (i’ve been using the body’s renderer to get it’s bounds and calculate for the tip).
I want to know if I can do it easier, without having to calculate where the tip should be each update. If I can just somehow nest the tip to the body and as the body scale progresses the tip will automatically follow
the thing is, the parent is not moving, neither is the body. just scaling. it’s pivot is static during the spell
Could you make the tip a child of the body? If your body pivot is on the left, move the tip to the right, then as you scaled the body, the tip would also scale and move with it. If you wanted the tip to maintain a constant size you could add a script to the tip (heh) that sets it’s scale to the inverse of the body on Update. Could be done in 1 line of code I would think.
Alternatively, you could make an empty GameObject a child of the body and then on Update set the tips position to the empty go’s position.
since the body’s pivot is on the left, it does not move, so even if the tip is a child of the body it won’t move either. I might have to do that moving the tip using the body’s bounds max and min after all
As long as the tip is a child of the body and their transform’s positions aren’t the same, the tip will move as the body scales. The distance between the tip and the body will scale proportionally with the scale of the parent. As an example, the child’s local x position is 1 unit from the parent’s x position. Scaling the parent on the x plane by a factor of 3 will mean the child is now 3 units away in the x.