- Home /
Question by
Prog_Meisters · Apr 02, 2013 at 12:04 AM ·
animationclickable
How to click on a game object and get it to move in formation with the character?
How can I click an object and then get it to become a child of the main camera and there would be an animation of it moving from where ever it was to a position under the camera?
Comment
Answer by robertbu · Apr 02, 2013 at 06:48 AM
You can do something like this to make an object a child when it is clicked on:
function OnMouseDown() {
transform.parent = Camera.main.transform;
}
To "Animate" it moving under the camera, use Vector3.Lerp() in Update() to change the transform.localPosition over time.