Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 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 /
This question was closed Apr 06, 2016 at 09:56 AM by bromley for the following reason:

I solved the problem myself

avatar image
0
Question by bromley · Apr 03, 2016 at 09:26 AM · animationdelaydooropenclose

Open Door Animation Problem

I've created a rotating door with these properties: alt text

alt text When I approach the door, I can press "E" to open the door: after that i pressed "E", the animation of opening of the door starts, so the door will be open. Now, if i want close the door i have to re-press "E" on the door, indeed after that i pressed "E", the animation of closing of the door starts, but this animation starts with some seconds of delay. This is a problem because i want that animation starts right after that i pressed "E", without delay.

The script is this:

 using UnityEngine;
 using System.Collections;
 
 public class Rotating_Normal_Door : MonoBehaviour {
     
     public bool open = false;
     public bool interaction = false;
     public bool locked = false;
     
     private Ray ray;
     private Animator anim;
     private int openDoor = Animator.StringToHash("Open");
     
     void Start () 
     {
         anim = GetComponent<Animator> ();
     }
 
     void Update () 
     {
         RaycastHit hit;
         ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
         if (Input.GetKeyDown ("e") && interaction == true && locked == false && Physics.Raycast (ray, out hit))
             {
                 if(hit.transform.name == name)
                 {
                     changeDoorState ();
                 }
             }
     }
 
     void OnTriggerEnter (Collider col) 
     {
         if (col.gameObject.tag == "Player")
         {
             interaction = !interaction;
         }
     }
 
     void OnTriggerExit (Collider col) 
     {
         if (col.gameObject.tag == "Player")
         {
             interaction = !interaction;    
         }
     }
 
     void changeDoorState ()  
     {
         if (open == false) 
         {
             anim.SetBool (openDoor, true);
             open = true;
         }
         else 
         {
             anim.SetBool (openDoor, false);
             open = false;
         }
     }    
 }
 

Somebody can explain me where am i wrong?

2.png (73.6 kB)
1.png (34.5 kB)
Comment
Add comment · Show 2
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 bromley · Apr 04, 2016 at 06:00 AM 0
Share

I noticed that the delay time of the closing door animation it's variable, it is about 1 second, but sometimes it's less and sometimes it's more.

avatar image bromley · Apr 06, 2016 at 09:55 AM 0
Share

I fixed it myself... I disabled the "Exit Time" from animator properties and now the closing door animation works fine.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

87 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

Related Questions

Need help getting my door to open and close without triggering other doors. 1 Answer

Open/Close Door only if player is near the Door 1 Answer

Help: My doors won't work properly >< 0 Answers

Door open/close sound effect?? 0 Answers

Animation won't play if not looked at 1 Answer


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