Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Senuska · Aug 29, 2017 at 05:09 PM · animationcollisionraycastanimatorvr

Animation on Raycast Not Playing

I am making a look-at menu system. I had it working last week, but it has broken on-device, using Unity 5.6.0f3.

I am building to the Samsung Gear VR (Android). Each menu item has the tag "Attraction" and is on the UI layer. On a hit a script will set a boolean called selected in the hit menu item's Attraction script.

 private void LookAtMenu()
     {
         RaycastHit hit;
 
         if (Physics.Raycast(mainCam.transform.position, mainCam.transform.forward, out hit, raycastLayers))
         {
             if (hit.transform.tag == "Attraction")
             {
                 if (hit.collider != attractionCollider)
                 {
                     if (attractionCollider)
                     {
                         attractionCollider.GetComponent<Attraction>().selected = false;
                     }
                 }
 
                 attractionCollider = hit.collider;
                 if (!hit.transform.GetComponent<Attraction>().selected)
                 {
                     hit.transform.GetComponent<Attraction>().selected = true;
                 }
 
                 debugOut = string.Format("Raycast hit attraction: {0}", hit.transform.name);
 
             }
             else
             {
                 if (attractionCollider)
                 {
                     attractionCollider.GetComponent<Attraction>().selected = false;
                 }
             }
 
         }
         else
         {
             //Debug.Log("Raycast hits nothing!");
             if (attractionCollider)
             {
                 if (attractionCollider.GetComponent<Attraction>().selected)
                 {
                     attractionCollider.GetComponent<Attraction>().selected = false;
                 }
                 attractionCollider = null;
             }
         }
     }

The Attraction script is just a SetBool method call to the attraction's animator.

 private void Update()
 {
     GetComponent<Animator>().SetBool("lookAt", selected);
 }

The Attraction's animator has three States, the default Idle, Active, and Inactive. When an Attraction's "selected" data member is true, the state changes to Active, and the animator plays the attraction's "active" animation.

When "selected" false, the state changes from Active to Inactive and plays the "active" animation in reverse. The state then automatically changes to Idle at the end of the reverse "active" animation.

The menu had worked just fine, but for some reason it recently stopped playing the "active" animation. I have tried placing the LookAtMenu() method in both FixedUpdate and regular Update, but there is no difference.

Any ideas?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Senuska · Aug 30, 2017 at 02:47 PM

So I found the issue. In a previous iteration of the menu I used a single Animation Controller (Main Menu Animation Controller) for the whole menu instead of individual Animation Controllers. When I implemented the new version with multiple Animation Controllers I took out the transitions from the default case in the Main Menu Animation Controller and had the individual Animation Controllers take over.

I left the old, disconnected Animation Controller on the MainMenu object. This did not pose a problem in the builds until recently when Unity decided that the disconnected Main Menu Animation Controller was the correct Animation Controller.

I removed the Main Menu Animation Controller and it worked on device.

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

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

Related Questions

How to Play an animation state on an animator controller on collision? 1 Answer

Play animation when 2d character hits collider. 0 Answers

Play Audio-Clip On Ray Casting Collision 1 Answer

Destroy object after time Only if raycast is colliding; 0 Answers

Raycasting Door Animator 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