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 DivideByZero · Mar 26, 2013 at 02:01 AM · animationcollider

Need help with some OnTrigger Scripting

I am currently working on a maze type game, and I have run into a problem that requires some scripting that I don't know how to do. My idea is that once the player has collided with the collider, a separate game object's animation is played in which it comes down and blocks the exit of the maze. I've done some OnTrigger scripting for stuff like teleporters before, but this one has got me confused.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Auggie · Mar 26, 2013 at 03:55 AM

what if you try something like this:

make two separate scripts-

 //attach this on the player gameObject
 
 function OnCollisionEnter ( collision : Collision ){
 
     collision.gameObject.SendMessage("PlayAnimation", SendMessageOptions.DontRequireReceiver);
 
 }

and make another for the object in the maze

 //attach this to a maze object
 
 function PlayAnimation()
     {
         gameObject.animation.Play("ClosingDoorAnimation");
     }


you can have the PlayAnimation() function on all of your maze object and just change the animation name inside that function.

i hope this helps...

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 DivideByZero · Mar 27, 2013 at 03:43 AM 0
Share

So I attached the first script to my character controller and 2nd to the collider that's supposed to trigger the animation of the door co$$anonymous$$g down, but nothing happened. I tried to mess around with the two scripts, but got no luck. $$anonymous$$gestions? Thanks!

avatar image
0

Answer by Chronos-L · Mar 27, 2013 at 04:09 AM

If you are looking for something similar to a trap trigger:

 public class RemoteTrapTrigger : MonoBehaviour {
    public GameObject trap;
 
    void OnTriggerEnter( Collider other ) {
       if( other.gameObject.CompareTag("Player") ) {
          trap.animation.Play("Activate");
       }
    }
 }

Attach this script to the trigger, assign the door/trap as the trap.

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

12 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

Related Questions

Multiple Cars not working 1 Answer

Trying to simply play this animation... Help please. 1 Answer

Animation Script Help 0 Answers

Reloading Help 2 Answers

My player won't jump? 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