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

Simple DOOR isn't working. PLEASE HELP.

Discussion in 'Scripting' started by ultraviol3nt, Oct 26, 2014.

  1. ultraviol3nt

    ultraviol3nt

    Joined:
    Jan 17, 2010
    Posts:
    155
    I have never used caps in a topic name until now. Here's why:

    Code (csharp):
    1. public bool isOpen;
    2.     [System.Serializable]
    3.     public enum DoorOpeningDirection { Inward, Outward}
    4.     public DoorOpeningDirection OpeningDirection;
    5.     public AnimationClip openingAnimation;
    6.     private Animator anim;
    7.  
    8.     public override void DoInteract()
    9.     {
    10.         networkView.RPC("openDoor", RPCMode.AllBuffered);
    11.     }
    12.  
    13.     void FixedUpdate()
    14.     {
    15.        anim = GetComponent<Animator>();
    16.        anim.SetBool("isOpen", isOpen);
    17.     }
    18.  
    19.     [RPC]
    20.     void openDoor()
    21.     {
    22.         if (isOpen)
    23.         {
    24.             isOpen = false;
    25.         }
    26.         else
    27.         {
    28.             isOpen = true;
    29.         }
    30.     }
    This is a script I have attached to a door. Everything animates, the rotation, the collider, everything moves the way it's supposed to, except for the renderer. The door's graphic stays completely still and will not move, but the box collider around the door moves exactly like you would expect it to. I tried it once with legacy animation and again with Mecanim. Both times I got exactly the same end result. I am literally at the end of the road and I'm sick of fighting this, because two people I've spoken to say everything is set up just fine and from the looks of it, it SHOULD WORK. This is a simple DOOR I've done so many times before, it's stupid. But now Unity decides to crap on me and tell me it's pretty much impossible?

    door_1.PNG door_2.PNG

    What, if anything, am I doing wrong?
     
  2. bobbylee

    bobbylee

    Joined:
    Aug 15, 2013
    Posts:
    49
    Are you sure your cube is not flagged as static?
     
  3. ultraviol3nt

    ultraviol3nt

    Joined:
    Jan 17, 2010
    Posts:
    155
    Positive.

    Issue was fixed, although I'm not sure how. In the debug inspector, there's a setting on the Animator called "Has Transform in Hierarchy". That was already enabled, but somehow disabling and reenabling is fixed it..