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 IceWraith180 · Jul 29, 2014 at 09:40 PM · animator

script Animation issues

Hello again!

I am trying my hand at some animations.

I have created a very simple door in blender animated it and imported it into unity.

Inside the .fbx there was one animation, just the door sliding to the side.

I first created a new Animator controller, in the animator tab I dragged the animation from the .fbx into the window to create a new State I think they are called.

The animation was on auto play somewhere so I read online that I need to create another state. So I did I created an empty state with the default name.

I added a bool to the animator of true and false, and called it open. after I made the new state the default and added a transition from the new state to the animated state.

It was no longer auto playing so that was good!

I started to write a script in c#

 Animator anim;
 
     void Start () {
         anim = GetComponent<Animator>();
 
     }
 
     void OnCollisionEnter (Collision col) {
 
         if(col.transform.tag == "player") {
         anim.SetBool ("open", true);
         }
     }

I thought this would make it so when the player walked into the collider of the door then the bool of open would be set to true and the door would play the animation, it did nothing. So I played around with the animator a little.

So I set the conditions of the transition from New State to Cube|CubeAction to be set to

open and true and the Cube|CubeAction to open and false

But it still does not work, so after a few youtube videos and many form posts I have come (yet again) here for help!

SOrry for this being so long, I thought the more information I provided the better!

Thanks for the help

Comment
Add comment · Show 3
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 tanoshimi · Jul 29, 2014 at 09:52 PM 0
Share

First things first - does your OnCollisionEnter() method get called at all? Put a Debug.Log('Got Here!'); before the anim.SetBool() line - does it print anything in the console?

Also, doors are typically opened by triggers rather than colliders - do you have the collider marked as IsTrigger?

avatar image IceWraith180 · Jul 29, 2014 at 10:07 PM 0
Share

Yes, OnCollisionEnter is being called, I used print("Hit") and it worked.

The door is not set to trigger either, making it a trigger just makes it so my player can walk into the collider.

O$$anonymous$$ so using what you said, I took another look at it, and set false to true and true to false, set it to a trigger, and changed it to OnTriggerEnter and then it worked.

i don't think I would of been able to get there without reading what you said so Thank you for your help!

avatar image Exbow · Jul 29, 2014 at 10:24 PM 0
Share

"I added a bool to the animator of true and false, and called it open. after I made the new state the default and added a transition from the new state to the animated state" did you properly added the transition from one state to the other to be according to the bool value?

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

2D Animation does not start 1 Answer

Ragdoll and Animator 0 Answers

uNet implementing bots with max players per connection 0 Answers

how do you align the location of parent with child bones when using animation? 0 Answers

Animation Keypress Trigger Problem 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