Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by Digital-Phantom · Jul 04, 2013 at 03:09 PM · animationcolliderstriggersexitenter

Problems with Sliding Door Animation (solved)

OK.. I'm suddenly getting problems with my door animations and I cant figure why.

Its a simple sliding door with 2 animations, one for open and one for close that activates as the player enters or leaves the 'trigger' area. I'm using a simple box collider that's been extended forwards and backwards around the door, together with a very simple script-

 #pragma strict
 
 //Puts Drag n Drop variable slot into Script
 var doorClip : AnimationClip;
 
 function Start () {
 
 }
 
 function OnTriggerEnter () {
 
     animation.Play("SlideOpen3"); // Sets name of Animation clip to be played
 
 }
 
 
 function OnTriggerStay () {
 
 }
 
 
 function OnTriggerExit () {
 
     animation.Play("SlideClosed3"); // Sets name of Animation clip to be played
 
 }

Everything worked fine until I added extra doors and now the animations play while the player is within the collision box (animations just played on enter and exit before)

Each door has its own animation and own script

At first I had all the doors from a prefab and realised this was changing settings on the other doors so I separated them all into individual parts and reset the scripts and animations. Now that's when the problem started, I'm guessing I don't have a setting correct but cant see what is wrong?

An easier way for me to put it I think is that the close door animation is playing whenever I move within the collision box (not just on exiting the box as it should)

Thanks guys (or ladies)

Comment
Add comment · Show 4
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 Owen-Reynolds · Jul 04, 2013 at 03:35 PM 0
Share

"...all the doors from a prefab and realised this was changing settings on the other doors": prefabs don't cause that problem.

Spawned prefabs are individual. They get their own copy of all script variables, animation states... (if they didn't, they'd be useless.) Not using prefabs just makes the whole thing harder to change and test.

Tested with only two doors far apart, walking in/out of each?

avatar image Digital-Phantom · Jul 04, 2013 at 05:07 PM 0
Share

Have tested with 1,2 and 3 doors but am still experiencing the same issues? What's most perplexing is that the problem has recently started where as it worked fine before ! I don't see why now even the smallest player movement while within the collision box is causing the animations to play?

avatar image Owen-Reynolds · Jul 04, 2013 at 08:02 PM 0
Share

Do a "regression." In a fresh scene, put the earliest version of the script, packed with Debug.Logs and public vars. $$anonymous$$eep adding and testing until the error happens (or copy the scene and keep deleting until it goes away.)

You probably added something that seemed totally unrelated but broke it, put the script on the player by mistake... . At worst you'll have a rebuilt copy of your scene that now works, and can compare part by part to see what is different and broken in the original.

avatar image killer-zog · Jul 04, 2013 at 11:25 PM 0
Share

use the Activatetrigger.js that comes with unity, and see if it works, it is the most useful script on playing animation with trigger.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Digital-Phantom · Jul 05, 2013 at 01:01 PM

OK.. Im officially a noob...lol

The problem wasn't my script OR my animation, It was me ! I hadn't taken into consideration that using a prefab door would of course give me a prefab box collider. So the problem was actually the size of my box (no innuendo plz) The newer doors had the same size collider but the newer doorways were slightly bigger. This meant that the box collider only covered half the open door space and as the player walked through that space the door opened and closed as the collider touched the player. As the door opened fully the collider thought the player had left the doorway and played the door close anim and as soon as it did it hit the player again and opened... DOH !

Anyway thanks for all your replies guys, you actually helped me to solve another little issue I had too.

Thanks, again

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 Owen-Reynolds · Jul 05, 2013 at 03:00 PM 0
Share

Answering your own question is fine. But generally ins$$anonymous$$d of adding "solved" to the heading, just mark your answer as correct.

Also, note how more careful testing would have solved this. It takes a long time to learn not to quit after the first error, and ins$$anonymous$$d pretend you're writing a bug report. For almost anything it pays off to quickly test the stuff you "know" can't be the problem (like walking just up to the edge of the door.)

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

17 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

Related Questions

continuing an objects motion 1 Answer

When inside trigger, turn object on, when outside trigger, turn off 1 Answer

Can't call GetKey inside OnTriggerEnter? 2 Answers

How can I change animation with colliders? Using AR and Vuforia. 0 Answers

How to animate collider along with object for 2D game? 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