Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 bekah_mbrown · Apr 06, 2019 at 04:44 PM · animationtriggeranimator controlleranimation controller

Animation begins at start of Gameplay before colliding with trigger

I have set up an animation which is supposed to start when colliding with a gameobject. However, this animation occurs at the start of gameplay. The animation is supposed to occur when colliding with gameobject, and stop when exiting the gameobject. The animation starts at beginning of gameplay, then when i collide it continues. Then when I exit the object it stops as it should. However, I do not want it to start at the beginning of gameplay. Below is an image of my Animator.

I have then linked an image of the code which shows that when entering the gameobject, the animation plays. And when exit the animation stops.

screenshot-701.png (19.8 kB)
screenshot-703.png (25.4 kB)
Comment
Add comment · Show 1
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 RobAnthem · Apr 06, 2019 at 04:48 PM 0
Share

You need to have a different animation state to transition from, so that default it's in an "idle" state and when collision occurs, you change a parameter in animator to move to next transition, usually a trigger or bool.

 [SerializeField]
 Animator m_Animator;
 [SerializeField]
 string animatorHash = "trigger";
 private bool collided;
 void OnCollisionEnter(Collision col)
 {
     if (collided)
         return;
     if (col.collider.gameObject.layer == layerIAmLookingFor)
     {
         collided = true;
         m_Animator.SetTrigger(animatorHash);
     }
 }

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Vollmondum · Apr 07, 2019 at 03:46 AM

You need to specify collidable object tag and only play that animatiin if collided with that tag trigger

Comment
Add comment · Show 4 · 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 bekah_mbrown · Apr 07, 2019 at 04:45 PM 0
Share

hey, not sure if I've done it right. The animation still occurs at the beginning of gameplay but will still proceed to then turn on and off if I enter or exit the colliision

alt text

screenshot-705.png (29.1 kB)
avatar image RobAnthem bekah_mbrown · Apr 07, 2019 at 05:29 PM 0
Share

You need to setup the Animator to have a default state that's not the one you want to play on triggering. Your animator trigger "Cylinder", how is the transition setup?

avatar image bekah_mbrown RobAnthem · Apr 07, 2019 at 05:49 PM 0
Share

So i have set up an idle state then attached my animation to it - and set up a trigger known as 'Cylinder'. alt text

screenshot-709.png (70.0 kB)
Show more comments
avatar image
0

Answer by bekah_mbrown · Apr 07, 2019 at 06:28 PM

Okay now when I play the lights are active at gameplay, then when the first time I collide with the trigger the animation occurs, then when I exit the trigger the lights turn off and the animation stops(which is what I wanted), but then when I collide a second time the lights still turn on but the animation stops. How do I get the animation to repeat?

alt text

alt text


screenshot-710.png (55.9 kB)
screenshot-711.png (59.5 kB)
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

278 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 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

Trigger not playing Animation 0 Answers

making an arrowgrab animation play when attackdelay = 0. 0 Answers

Animations don't work with humanoid avatars 0 Answers

Animator Button Plus Transition 0 Answers

Display additional animation on top of other animations 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