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 jakedemian · Apr 28, 2017 at 07:06 PM · animationunity 52dcollisiontrigger

How do I make animation transitions a one-way street?

I am making a platformer. I have already set up idle and run animations for the player, and I've imported them all into an animation controller. There are some other animations, but I'm going to focus on the two states that are inside the red box.

alt text

Transisition 1 is the jump event, Transition 2 is the landing event. When the player hits the spacebar and is touching the ground, I set the TriggerJump trigger, and when they land again, I set the TriggerOnGround trigger.

Here are how these transitions are set up in my animation controller:

alt text

alt text

My animator is set up properly in my code, as the idle -> running and running -> idle transitions work fine (they're boolean).

When the user hits space and the player is grounded, I execute

 anim.SetTrigger("IsJumping");

and when the player enters a collision with the ground I call

 anim.SetTrigger("TriggerOnGround")

The way I THOUGHT these triggers worked was that in once you call a trigger and a transition from one state to another occurs, you are stuck in that state until some other trigger gets it out of there. There is only one place in my code where I call TriggerOnGround, so I've set a Debug.Log() there to show whenever this is called.

So after all that setup, here's my problem.

As soon as I hit the spacebar, the player quickly flashes to the jump animation then immediatly back to the idle animation. My above mentioned Debug.Log() shows nothing, so the TriggerOnGround event cannot be getting called, so somehow this animation controller is getting from the jump state to the idle state without my manually calling TriggerOnGround.

MORE INFO AFTER SOME RESEARCH:

What's happening is the transition is backing up on itself, and I don't know how to prevent it. If I mute every other transition in the scene except for transition 1, then there should be no way to get out of the PlayerJumpAnimation state. However, even when I mute all other transitions besides 1, I am still seeing this exact same behavior. That means that the state machine remembers it's previous state, and the transition it took to get there. When the trigger is activated, it goes through the transition from Idle -> Jumping, and when the trigger is set back to false interally, it goes BACKWARDS through the transition to the original state. Is there some way to prevent this backup from happening? I want these transitions to be one-way streets.

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

Answer by Matt1000 · Apr 29, 2017 at 02:40 PM

I'm sorry to tell you but transitions are NOT supossed to be bi-directional... they ARE a one-way thing. What I'd reccommend is to simply change that trigger to a boolean. And simply create one (e.g: Jump) and whenever it starts you set it to true and when OnGround you set it to false. I've always done that and worked perfectely;

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

245 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

Related Questions

Animate gameobject when collided with another gameobject using VRTK 0 Answers

2d game end level with trigger and colission with trigger who to make a if condition 1 Answer

How to handle animation of multiple Coins? 1 Answer

Attaching multiple animation events to player 1 Answer

2D platformer. Let player slide under object. 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