Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
avatar image
2
Question by TheGeekyDead · Nov 24, 2013 at 01:26 AM · animationtriggerdoor

Created an Open Close Animation, but script wont activate both doors?

I have a sliding door, i already made the 2 animations for each door. Open and Close, i have the collider set as a trigger, and a sound on the trigger object. When i walk into the collider i hear the sound but only the right door slides open? And if i exit the collider i only the right door slides closed.

SO why is the left door not opening? it is animated properly i tested it. I added them in order under Animation: 1,2,3,4

 private var enter : boolean;
     
 function OnTriggerEnter (other : Collider){
     if (other.gameObject.tag == "Player") {
     enter = true;
     animation.Play("SlidingDoors");
     animation.Play("SlidingDoors3");
     audio.Play();
     }
 }
 
 function OnTriggerExit (other : Collider){
     if (other.gameObject.tag == "Player") {
     enter = false;
     audio.Play();
     animation.Play("SlidingDoors2");
     animation.Play("SlidingDoors4");
     }
 }

Any help would be nice, it's driving me crazy i must have missed something. Update: SlidingDoors = Left Door/Open, SlidingDoors3 = Right Door/Open. SlidingDoors2 = Left Door/Close, SlidingDoors4 = Right Door/Close.

Comment
Add comment · Show 8
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 Moor · Nov 24, 2013 at 05:13 AM 2
Share

where u added this script,

avatar image Fornoreason1000 · Nov 24, 2013 at 05:30 AM 0
Share

are the animations stored on the doors themselves or the parent of them? if the animations are stored on the separate doors you need to add the script to the left door as well.

avatar image TheGeekyDead · Nov 24, 2013 at 09:06 PM 0
Share

@ $$anonymous$$oor, (where u added this script,). Umm as i said above i have it on my Trigger Object.

@ Fornoreason1000, i tried several variations of that. 2 triggers/1 trigger both doors as children it just would not work.

But i got it solved now thanks to ( GameVortex ) below!

avatar image Bunny83 · Nov 24, 2013 at 09:38 PM 0
Share

@TheGeekyDead:
I removed the "solved" in the title since that's not part of the question. A question should not include an answer or anything related to an answer. A question is marked as solved by picking an answer (which you already did).

I also removed all of your tags. Tags should represent your actual problem with short keywords. Things like "help", "code", "error" or "script" are useless. I've replaced them with more appropriate ones.

avatar image Bunny83 · Nov 24, 2013 at 09:42 PM 0
Share

Also, ppl, don't forget to vote (i don't talk to TheGeekyDead since he can't vote yet). If no one votes questions up all those who just ask questions but don't post answers never get any karma. So you can't get upvotes from the person.

We have really a lot bad and very bad questions here, but this one is clearly a good one.

edit
I'm just wondering where's the facebook and youtube generation? It's kind of strange that on StackOverflow votes are kind of spammed around, but here it looks like people fear they could loose something if they vote something up.

I don't want to make you spam votes, this is a knowledge base and everyone who thinks he can judge if a question / answer is good should vote.

Show more comments

1 Reply

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

Answer by GameVortex · Nov 24, 2013 at 08:58 AM

You are playing both your animations on the same object. This means that when you play the animation "SlidingDoors3" it stop the other animation "SlidingDoors" from happening. I would recommend separating them out and have the animations play on their own objects. Something like this maybe:

 private var enter : boolean;
 public var leftDoor : GameObject;
 public var rightDoor : GameObject;
  
 function OnTriggerEnter (other : Collider){
     if (other.gameObject.tag == "Player") {
     enter = true;
     leftDoor.animation.Play("SlidingDoors");
     rightDoor.animation.Play("SlidingDoors3");
     audio.Play();
     }
 }
  
 function OnTriggerExit (other : Collider){
     if (other.gameObject.tag == "Player") {
     enter = false;
     audio.Play();
     leftDoor.animation.Play("SlidingDoors2");
     rightDoor.animation.Play("SlidingDoors4");
     }
 }

Remember to assign your doors in the inspector.

Comment
Add comment · Show 1 · 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 TheGeekyDead · Nov 24, 2013 at 08:53 PM 0
Share

Ahh thanks man, i knew i was missing something. So i had to define each door as an object, i had all 4 animations on the trigger it's self lol. /Facepalm

So i Updated the script, and i had to re-make the animations for each door, because they reset for some odd reason when placing it on a new object. (Animation: Practice makes perfect) i was able to make them look way better when opening this time and the ti$$anonymous$$g. But now it works 100% i walk up it beeps and the doors slide open, i leave the trigger it beeps and they slide closed!

I even tested it with my enemy AI, when he wanders up it activates the error code "lights flash" (doors lock) and the guns shoot him and i have to disable the alarm. (i updated the script since i posted it) i added a lot more stuff like my Alarm+$$anonymous$$eypad.

But thanks for the help. i will keep that in $$anonymous$$d for future objects and switches with more than one animation haha.

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

20 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

Related Questions

play a door animation with collider 1 Answer

Trigger Door Animation 2 Answers

Presure plate that triggers an animation 1 Answer

Sliding door animation question. 3 Answers

Triggering door animation with collider 2 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