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 /
This question was closed Jan 30, 2014 at 12:32 PM by hollym16 for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by hollym16 · Jan 22, 2014 at 02:25 PM · animationanimatorbooleancycle

Scripting animations

I've done some research but not sure how to phrase this one concisely. What I'm looking to do is have my human shaped model change animation on a button click.

I've got this human model which has a number of animations that I've set up to loop by dragging them into the Animator (such as Idle, Walk etc.). This all works fine. However, when I click a button I then want it to play a different animation, then return to the loop. I've tried the standard Raycast with animation.Play(); function but it brings up the error message that theres no animation attached to the GameObject (even if I add the Animation component to the Inspector).

I believe there's a different script thats appropriate to use, something that includes booleans? Can anyone point me in the right direction?

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

  • Sort: 
avatar image
0

Answer by VildNinja · Jan 22, 2014 at 02:37 PM

You haven't really given a lot to work with, but a few possible reasons is that you model either doesn't have a collider, so the ray goes right through it and hit something in the background. Or some of the child elements have colliders and are being hit instead of the parent object.

First step is to print the name of the object you hit. If this is the name of your model the raycast is done correctly. If not then make sure to add a collider only to the parent object, the one with the animation component attached.

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 hollym16 · Jan 22, 2014 at 02:44 PM

Sorry I haven't been very detailed, I'm not really sure how to phrase it. Basically, when importing a model with animations on it, how do I code it so I can change to a different animation when I click a button?

For example, my model is idling by default but when I click a button I want it to play the walk cycle then return to idle.

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

Follow this Question

Answers Answers and Comments

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

Related Questions

My animation keeps on repeating on my animator 1 Answer

Door script not completely working help! 1 Answer

Is it possible to use the previous animation? (not animator) 1 Answer

cannot implicitly convert type void to bool 1 Answer

Blend Tree Transition Conditions. 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