- Home /
Enter Trigger, play animation(s) and sound FX
I've been testing a few Java scripts for playing animations when my player enters a triggered area, but I had too much problems creating at my own.
What I need is a script that whenever my player enters a triggered area, I want at least 2 animations to play at the same time and also an Audio Source (otherwise known as a sound FX)
Here's what I mean with those two animations:
- Making GameObject's rotating and moving 
- GUI transition (Fade effect) 
Both of my animations are ready, just need a function in order to activate them. If you guys have a good way to solve this question, post them below! I would appreciate it :)
Thanks!
Answer by aldonaletto · Jul 01, 2013 at 12:33 AM
Just write an OnTriggerEnter event to call both functions (trigger script):
 function OnTriggerEnter(other: Collider){
   if (other.tag == "Player"){ // remember to tag the player as "Player"
     StartAnimation1();
     StartAnimation2();
   }
 }
NOTE1: The player must be a rigidbody or a CharacterController in order to be detected by the trigger.
NOTE2: Be aware that you can't rely on Time.deltaTime inside OnGUI: calculate the alpha value in Update or a coroutine, and use it inside OnGUI.
Your answer
 
 
             Follow this Question
Related Questions
play GUI animation from script? 0 Answers
Trouble getting GUI phone to open/close 1 Answer
Created game objects rollover show guy text 0 Answers
Handling Movement - Animations 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                