Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
2
Question by matp86 · Oct 31, 2016 at 07:23 AM · animationanimatortriggergetcomponent

Error: MissingComponentException: There is no 'Animator' attached - Animator is attached but disappears on play. Can anyone fix?

My script:

 using UnityEngine;
 using System.Collections;
 
 public class TriggerElevatorDoors : MonoBehaviour 
 {
     public    Animator anim;
     bool areDoorsOpen = false;
 
     // Use this for initialization
     void Start () 
     {
         anim = GetComponent<Animator>();
     }
     
     // Update is called once per frame
     void Update () 
     {
         
     }
 
     void OnTriggerEnter(Collider openDoorCollider)
     {
         Debug.Log ("Elevator door triggered");
 
         if(!areDoorsOpen)
         {
             // elevatorDoorsController.SetTrigger ("ElevatorDoorTrigger");
             anim.SetBool ("isOpen", true);
             areDoorsOpen = true;
         }
         else
         {
             anim.SetBool ("isOpen", false);
             areDoorsOpen = false;
         }
     }
 }
 

I have a trigger set to open an elevator door. When triggered I get the error:

MissingComponentException: There is no 'Animator' attached to the "ElevatorDoorTrigger" game object, but a script is trying to access it. You probably need to add a Aniamtor to the game object "ElevatorDoorTrigger". Or your script needs to check if the component is attached before using it.

The problem is that the Animator is definitely assigned but when I click play it disappears. I can't seem to find anyone else having this issue, might be searching for the wrong thing.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by matp86 · Nov 01, 2016 at 09:09 AM

Fixed it. Took out line 16:

 // anim = GetComponent<Animator>();

The animator component is part of a different GO.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Cynikal · Oct 31, 2016 at 08:16 AM

Is this the ONLY script attached to the gameobject?

You can try adding:

 [RequireComponent (typeof (Animator))]
 public class TriggerElevatorDoors : MonoBehavior
 {
 ...
 }

Does ANYTHING else reference the gameobject?

And lastly, are you sure you're not adding the component in play mode...then when you click play (back to edit mode) it reverts?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by matp86 · Oct 31, 2016 at 11:16 AM

@Cynikal Thanks for answering.

In order:

  • It is the only script attached.

  • Added that code but no luck.

  • Nothing else references the gameobject.

  • I'm not adding anything during play mode.

I'm new to animation and the animator in Unity, I very much appreciate the help!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

148 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do i extend a animation ? 1 Answer

How to call Animator from another script 0 Answers

Playing animation without hold the button 1 Answer

About the door animation trigger 0 Answers

Problems with using the same Animator Controller on multiple objects. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges