- Home /
Play iTween on instantiated prefab
I have a prefab which contains several gameObjects that each have an iTween event on them. I'm instantiating it with a trigger, and then need to play the tweens.
Normally I'd just use
iTweenEvent.GetEvent(Train1, "Train1").Play();
to play the tween, but I understand I can't do that on prefabs.
I understand I need to use GetComponent to access the iTween component, but although I've scoured the forum, Answers and the script reference, I can't figure out how to do it.
Thanks in advance :)
Why don't you assign the gameobject you instantiate to a gameobject variable and use that to GetEvent and play it?
Answer by Montraydavis · Oct 30, 2012 at 09:14 AM
var iTweenObject : GameObject = Instantiate ( MyObject, transform.position, Quaternion.identity )
iTweenObject.DoTweenEventAndCodesHere ( )
Thanks, I ended up doing it differently in the end, but I can see how that would have worked too.
Your answer
Follow this Question
Related Questions
Access a function of an instantiated prefab 1 Answer
Get Component from Instantiated Prefab 1 Answer
How to reduce usage of GetComponent()? (instantiate, prefabs) 0 Answers
How to instantiate a prefab after a certain action happened? 2 Answers
Accessing prefab data before instantiation breaks prefab? 3 Answers