Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Animation not working

Discussion in 'Getting Started' started by Petras99, May 30, 2016.

  1. Petras99

    Petras99

    Joined:
    May 29, 2016
    Posts:
    27
    I am trying to make an animation where when the player makes it pass the finish line a GUI image changes from alpha 0 to full. However when i pass the finish line nothing happens.

    Code (csharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5.  
    6. public class FinishedLevel : MonoBehaviour {
    7.  
    8.     public GameObject player;
    9.     public Collider finishedLevelC;
    10.     public int whatLevel;
    11.     Animator anim;
    12.  
    13.     void Awake(){
    14.         anim = GetComponent<Animator> ();
    15.     }
    16.  
    17.     void OnTriggerEnter(Collider other)
    18.     {
    19.         other = finishedLevelC;
    20.         anim.SetTrigger ("NextLevel");
    21.      
    22.     }
    23.  
    24.  
    25.  
    26. }
    27.  
    28.  
    So what i have done is assigned an animator component to the GUI Canvas, and the code script from above. I assigned my player to the script and the finish line box Collider to the script also. I have created an animation clip that is supposed to change the alpha on the GUI image from 0 to 1 at 1.30 seconds, i have an animation controller that has a transition from empty to the clip. I assigned the animation controller to the Canvas animator component. I have not been able to get this to work, any help is appreciated!

    I also have a question. This is supposed to be for the Next Level screen. So i am wondering if a better way to have a Next Level screen, is make a whole different scene, and avoid all that all together?
     
    Last edited: May 30, 2016