- Home /
How to track top of scaled object ?
Hello.
Is there any way to track a top of scaled object ? I have a small cube spawned on the bottom of screen and it scaling up to top of screen. But position of this cube is still on the bottom of screen.
I want that a small ball (child of cube) be at the top point position of scaled cube all the time. But i cant track it with cubes position because it is still on the bottom of screen.
Any help ?
Comment
Answer by Anis1808 · Dec 04, 2019 at 12:09 AM
I suggest you just compute it programatically
float yPositionOfBall = cube.transform.position + cube.GetComponent<MeshRenderer>().bounds.size.y/2;
If you want to put the circles bottom on the square's top then use
float yPositionOfBall = cube.transform.position + cube.GetComponent<MeshRenderer>().bounds.size.y/2 + ball.GetComponent<MeshRenderer>().bounds.size.y/2;