- Home /
How can I make that two events starts when something else happens?
Hi everybody. I need some help, i have been looking around for the answer but can't figue it out. I made some turtles, they have a walk animation but they dont move foward, so I attached a Move Foward script. Everythig right, but now I need that both animations starts only when the player (FPS) puts an object (A magic stone) on it's place (a magic totem). I have tried On trigger enter or, On trigger exist but is difficult to me realize how can i connect all the parameters in order them to work perfectly.
Thanks a lot!!!!!!
It is really a very simple one, and i put it in order that my turtles move foward. The animation is set as play automatically:
private var myTransform : Transform; function Awake () { myTransform = transform; }
function Update () { myTransform.Translate(-0.05, -0.005, 0.006); }
Answer by IceCreamTruck · Nov 05, 2010 at 01:30 AM
Okay. I'm guessing your problem is, you have multiple scripts and within each scripts, there are functions you'd like to call? Like skovacs has commented, you might wanna post your script because we can't really see what's going on here.
But, if I guess correctly, this might help you a bit..
Your character have an animation you wanna play, let's say animation01. Create a function inside the script (let's say the script name is charScript) attached to your character to play this animation, something like this,
function PlayThis() { animation.CrossFade("animation01"); }
Now, when you want to access this, depending on from where you wanted to access it, either use
GetComponent("charScript").PlayThis(); - if the two script are attached to the same game object
or
GameObject.Find("theNameOfYourGameObject").GetComponent("charScript").PlayThis();
Hope this helps :)
Thanks Im gonna work with that!!! Hope I can figure it out!!