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
-1
Question by Christopher Travis · Apr 14, 2011 at 01:31 AM · animationcollidertrigger

Trouble getting a trigger to activate an animation

Hi, im having trouble getting a trigger i have to play an animation on a chest to open the lid. I have a mesh collider on the "Chest1" and have istrigger ticked and have an animation on it aswell with "Take 001" in the animation slot. Ive also got a rigid body on my "Player" which is the first person controller incase thats the reason it wouldnt play. i want it so that once the "Player" reaches the "Chest1" it would start the animation "Take 001".

I have no idea on scripting made the script im using from some previous guidance. Would appreciate any help in correcting this.

Thanks in advance

function OnTriggerEnter (Player : Collider) {
animation.Play("Take 001");
}

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 Justin Warner · Apr 14, 2011 at 01:58 AM 0
Share

Well, in the function, I'd put in print("Test"); and see if that prints to see if the actual trigger is actually getting triggered...

avatar image Christopher Travis · Apr 14, 2011 at 02:11 AM 0
Share

ok, sorry im totally new to this, its for a university project. But what does that actually mean? how would the code change, as in where do i type print("Test") and wat would i be expecting to see from a success or failure?

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by matchstickct · Aug 06, 2013 at 05:42 PM

Took me most of today to figure this one out. When you are importing basic (non-rigged) animations from max, you need to make sure they are checked as 'legacy' on the importer in unity (you can find this under the 'rig' tab in the importer).

When I did this your script worked.

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
avatar image
0

Answer by Justin Warner · Apr 14, 2011 at 03:29 AM

  function OnTriggerEnter (Player : Collider) {
    print("test");
    animation.Play("Take 001");
  }

This'll print something in the Log.

Comment back and I'll help as much as I can, but off to bed for me, I'll reply in ~8-9 hours.

But tell me if this does or doesn't print Test when you enter the trigger.

Thanks!

Comment
Add comment · Show 14 · 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 Christopher Travis · Apr 14, 2011 at 02:33 PM 0
Share

thanks for the help so far. I used the code u suggested, when i moved over the chest which is the trigger it came up with a little speech bubble with an exclamation mark in and said test next to it. When i clicked it this opened up,

test UnityEngine.$$anonymous$$onoBehaviour:print(Object) NewBehaviourScript:OnTriggerEnter(Collider) (at Assets/NewBehaviourScript.js:2)

then if i click that it opens up the edit script page. Does this mean the trigger works? if so can you think of a reason why it wont play the animation then.

Thanks

avatar image Justin Warner · Apr 14, 2011 at 03:52 PM 0
Share

Alright, this means that YES, the trigger is being... tripped? Haha. But anyways, if I was to guess, your animation is not named right. Also, is the animation on the object that is hitting the trigger? Or on the object with the trigger?

avatar image Christopher Travis · Apr 14, 2011 at 04:14 PM 0
Share

ok haha so atleast ive done that bit right. ok the animation is on the chest which is the trigger. Ill look at rena$$anonymous$$g it then see if that helps.

avatar image Justin Warner · Apr 14, 2011 at 04:17 PM 0
Share

Is the script also on the chess than? I'd assume it is... Or is it on the player?

avatar image Christopher Travis · Apr 14, 2011 at 04:42 PM 0
Share

the mesh collider on the chest is acting as the trigger, and ive gt the animation attached to the chest aswell. Should i have something else so that my object isnt the trigger? i saw that is an activate trigger script in standard assets bt i dotn no how to apply that. As i said my script myt nt be right for what i am after doing, if you have a suggestion of some code that would be, im happy to use that, The name of object with the animation on is "Chest1" the name of the animation is "Take 001" and ive named my first person controller "Player" who i want to activate the trigger.

Show more comments

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

Animation not playing but trigger works 1 Answer

Destroy trigger so animation only plays once. 1 Answer

Having a door dissapear once a key is collected 1 Answer

How do you set up a trigger animation without going through the collider? 0 Answers

Trigger transition to another animation. 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