- Home /
Scaling Animation for a Instantiated Object
Hi, I am trying to do an app in which every time clicked, I Instantiate gameobject from the array of prefabs one by one. I need something like, as the object getting instantiated, it should also be scaled from 0,0,0 to 1,1,1 as a animation. But when we use Instantiate in c#, only we are able to show the object. But cant do the scaling while it is shown. While instantiating i call the following function by sending it the latest object which got instantiated.
void scaleUp (GameObject gameO) { while (gameO.transform.localScale.x <= targetScale.x) { gameO.transform.localScale += new Vector3 (0.1F, 0.1F, 0.1F); } }
How to handle Instantiating and Scaling at the same time simultaneously.
Thanks Jeeva
Perhaps look at the answer to this question: http://answers.unity3d.com/questions/582223/scaling-objects-over-time.html
Thanks for the reply.. But what you have suggested works well for the normal gameobjects which are in the scene. But while dynamically instantiate the prefabs, i am facing problem to scale. (The object should get instantiated along with the scaling animation)
Have you tried using Animations/Animator? That's what I used in AccuCentre (Windows/Android) to instantiate the shapes getting spawned to scale from 0 to 1.25 and then back to 1 to make it look like it "pops" onto the screen.
Hi sterlingSoftworks.. Thanks for the tip!.. This is what i wanted exactly. But i need to try and work out how to communicate from Instantiate() to animator/animation using script while spawing...!!! could u be of some help?? (Dont know where to start just give small startup plzz)
thanks
Jeeva
Answer by Jeeva3m · Jun 01, 2015 at 01:16 PM
Thanks Sterling Softworks for your help!... I tried scaling the instantiated objects by using Animator/Animation... Now i got what I wanted. I did the following to make what i want: 1. Before making the objects as prefab, I added animation in animator -scaling 0,0,0 to 1,1,1 in the timeline 2. Added a small script which gets the animator component, and a public variable through which we can set values to animator 3. Now when I instantiate the prefabs, automatically value set to animator and scaling animation happens...
Thanks...