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 Christoff · Nov 03, 2010 at 04:17 PM · animationtriggercharactercontroller

Animation trigger?

I have a shutter like door which I have animated in 3ds max, i have imported this into unity and split the animation so i have an idle state starting from frame 1 ending on frame 2. I also have a open animation starting frame 2 to 100.

I have a cube box that i want to be the trigger for playing the animation, ie once the first person camera hits the box with the mouse the animation will play.

Please can anyone help me on how I should go about doing this?

Thanks

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
1
Best Answer

Answer by skovacs1 · Nov 03, 2010 at 05:03 PM

The first person camera hits the box with the mouse?

While the thought of the camera GameObject or some script with the ability to reach out into the world to grab the mouse and then use it to physically assault a box sounds like good times, I'll answer this question assuming that you meant something like "How do I trigger an animation when the mouse clicks on a box?"

clickAnimation.js (Attached to the box)

var door : GameObject; //Assign this in the editor or in Start, find the door

function OnMouseUp() { door.animation.Play("Open"); }

Comment
Add comment · Show 8 · 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 Christoff · Nov 04, 2010 at 10:01 AM 0
Share

O$$anonymous$$ay if this is the case how do you assign the door to the editor?

thanks

avatar image skovacs1 · Nov 04, 2010 at 03:18 PM 0
Share

Select the object with the script attached and drag the door onto the door slot in the attached script in the inspector.

avatar image Christoff · Nov 05, 2010 at 11:39 AM 0
Share

okay but there is no door slot, just the name of the script once it's on the object.

do you need a var = door ? ..

avatar image Christoff · Nov 05, 2010 at 11:42 AM 0
Share

lol so sorry about this must be anoying , im new to unity . but the error console still displays expecting ; .. is this script correct .. and still having the problem dragging the door to the script.

avatar image skovacs1 · Nov 05, 2010 at 01:58 PM 0
Share

Fixed. Sorry about that. You should have mentioned the error. I'm flipping between c# and javascript so often that I sometimes screw up the syntax. Once the script compiles (without errors) it will have the door slot. Attach it to the box. Drag the door that has an animation named "Open" onto the door slot of the box's instance of the script.

Show more comments
avatar image
0

Answer by corriedotdev · Mar 18, 2013 at 10:35 PM

 var Animator : GameObject; //Assign this in the editor character with animation
  
 function OnTriggerEnter(){
     Animator.animation.Play("Open"); // name the animation to be played
 }
 
 
 Attach script to empty cube. This method is if you dont want to add a mouse click :)
 
 
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

1 Person is following this question.

avatar image

Related Questions

Does a mesh collider animate? 0 Answers

Basic animation key press 0 Answers

How to trigger animations in a script using character controller ? 0 Answers

How to have other (any) Objects smoothly push a Character Controller? 1 Answer

Animation not working correctly, character is going up 0 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