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 adjnor · Oct 15, 2015 at 01:11 AM · animationanimatortransitionstate machinecondition

Animator dont transition to self or any sub state

Hello,

Here is a picture to explain what I want to achieve: alt text

As you can see, AnyState transitions to JumpAndFall when isGrounded is false, and has can transition to self disabled. The problem is that when the state transitions to wallJump or doubleJump from JumpAndFall, then if isGrounded is true, since the current state is not JumpAndFall, it will transition to the state and then to wallJump or doubleJump again depending on which condition is true. So basically I want to stop AnyState from transitioning to JumpAndFall again as long as the current state is JumpAndFall or any of the "child" states (i.e. states that can only be transitioned from JumpAndFall), in this picture this means as long as the current state is one of the 3 states in the red circle, then don't do the transition from AnyState.

Is there any way to do this? Thanks

untitled.png (109.7 kB)
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

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

Answer by GiyomuGames · Oct 15, 2015 at 02:13 AM

How about: making the transition from your Anim state (I assume this is the state when you character is on the ground) to JumpAndFall when isGrounded is false making a transition from Any state to Anim when isGrounded is true or make 3 transitions (from each of your jump states) to Anim when isGrounded is true ?

Therefore when isGrounded becomes false the animator will be stuck in your red circle, until isGrounded it true again where you come back to your initial state.

Comment
Add comment · Show 5 · 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 adjnor · Oct 15, 2015 at 02:32 AM 0
Share

Thank you for your answer, this solution works for the example posted. However, when I will have more states that transition from my runAnim state (the state that you call Anim because we can't see the full name on the picture), I will have to add a transition for each of them to the JumpAndFall state with the isGrounded false condition. Also, I won't be able to use AnyState anymore since again, if I have a state e.g. sprinting that transitions from runAnim, then if isGrounded is true since the state wont be runAnim anymore it will transition again and we're back to square one. I can use transitions for each state that should go to JumpAndFall when is grounded is false but I want to avoid having too many transitions. I posted a solution of my own actually involving state machine behavior which to be honest I don't think is much better but for now I'll just wait a bit before deciding what is the accepted answer (my answer isn't showing up yet though). Thanks for the reply! :)

avatar image GiyomuGames adjnor · Oct 15, 2015 at 05:13 AM 0
Share

It's just a thought but you could add the condition "Vspeed == 0" in your transition from AnyState to JumpAndFall. This way while you are in the air the transition won't be called.

avatar image adjnor GiyomuGames · Oct 15, 2015 at 11:58 AM 0
Share

Right, but the problem is that since Vspeed is the vertical rigid body velocity, when I arrive at the peak of the jump, Vspeed will become 0 (going from positive value to negative), so even if I'm in the air, the condition to go to JumpAndFall will still be true. So it seems like besides my own solution with the state machine behaviour script, I would need to add quite a few transitions to make it work.

Show more comments
avatar image
1

Answer by adjnor · Oct 15, 2015 at 09:43 AM

Ok I found how to do this: I created a new bool variable called inAirState in the animator controller, then created a state machine behavior that I put on all 3 states JumpAndFall, doubleJump and wallJump. In the smb script, I set the inAirState bool to true on state enter, and set it back to false on state exit. Finally, the condition to go from AnyState to JumpAndFall now also has inAirState = false, thus while the current state is any of the 3 states in the red circle (above picture), the inAirState bool will have been set to true, otherwise it'll be false. This works but I really feel like it's not a great solution, I thought there could be way to organize my hierarchy maybe with a sub state machine somehow to achieve this but I don't know how. For now I won't mark this as the answer in case somebody comes up with a better way, if nobody replies I'll just put this as the accepted answer.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Identifying a transition to self in StateMachineBehaviour 0 Answers

Create animation transitions via script. 0 Answers

Animation State Machine Script Control Issue 1 Answer

How to make a transition animation, intermediate animation between two main states 0 Answers

State Machine Behaviour public variable not assignable from editor? 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