Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question AnimatorController Help

Discussion in 'Animation' started by LasJJ, Aug 25, 2022.

  1. LasJJ

    LasJJ

    Joined:
    May 31, 2022
    Posts:
    10
    How do you trigger an object's AnimatorController, by using a different game object to trigger that AnimatorController - I am using on mouse button down(). (an example is a keypad triggering a door animation - using the keypad object to trigger the door object). I keep getting this message (Animator is not playing an AnimatorController). I have used --- otherObject.GetComponent<Animator>(); and public GameObject otherObject; to reference the other object. Any help Please
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,149
    It's not clear if you're asking an Animation question or a Physics question. Are you asking how to use triggers or how to perform a certain action on an AnimatorController?

    Maybe this is just a basic scripting question.
     
  3. LasJJ

    LasJJ

    Joined:
    May 31, 2022
    Posts:
    10
    I think it's an animation question, but I'm not certain. The idea is to click on a certain game object in order to activate another game object's animation, using parameter trigger. But in the console log, I keep getting the message - (Animator is not playing an AnimatorController). I have referenced the intended Animator and GameObject, but still having this error. Please help.
     
  4. NarutoU21

    NarutoU21

    Joined:
    Sep 27, 2020
    Posts:
    19
    hey @LasJJ can you share the code or script snippet. I think i got your problem.
     
  5. LasJJ

    LasJJ

    Joined:
    May 31, 2022
    Posts:
    10
    public class TriggerScript : MonoBehaviour {
    public GameObject otherObject;
    Animator anim;

    private void Start()
    {
    anim = otherObject.GetComponent<Animator>();
    }

    private void OnMouseDown()
    {
    anim.SetTrigger("Active");
    }
    }

    This should reference the other game object. "Active", is the name of the trigger from the animator of the other game object. On the inspector tab in unity, I drag and drop the other game object in the public variable.
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,149
    Yes, this is nothing to do with physics at all. I don't see how it could be confused with physics. Anyway, I'll move your post.
     
  7. LasJJ

    LasJJ

    Joined:
    May 31, 2022
    Posts:
    10
    Apologies