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 /
  • Help Room /
This question was closed Sep 26, 2019 at 09:45 PM by Tyooo for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Tyooo · Sep 26, 2019 at 06:49 PM · animatoranimator controllertransitionstate-machinecondition

Getting Condition Value From Animator Transition in Script?

So, I'm really wanting to somehow obtain an animation transition's condition value in script, but I'm not coming out with any answers as to how I could do this.

To be clear, I'm trying to get the value that the condition needs to be to do a transition, not what the condition variable actually is. And I'm not doing this when I'm animating, I'm doing this for initialization.

For full context, I've got actions which are simply objects representing an animation the player might do. Each action has a corresponding state in the animator. Each state in the animator has several transitions leading to other attacks using an integer parameter. However, I require a representative for each of these "combo actions" an action has at run time. I'm currently getting by with essentially duplicating stuff I already know - based on the transitions an action has going out and using the integer value as an index, on each action resource I create an array of all the actions that it combos with.

Now, obviously, if I'm doing this for every action this could get tedious real quick, and since I'm already using the logic of an array to determine combos in the animator I figure it should be trivial to just initialize each action resource based on the info already in the animator - for each state, I could check the state's transitions and assign each action resource's combo array based on that information.

That's what I thought. I'm able to check through each and every transition of a state, and obtain the corresponding destination state, but I can't figure out how I can get the condition information I need. The AnimatorCondition class paradoxically has nothing I can see for identifying the condition.

So, I have my array of combo actions, but I don't know what indices they should be. That's where I'm stuck now.

And, I suppose I should admit that what I have does work, and it works well enough. But I'd really like to set up each attack once and be able to keep on going, rather than spending time duplicating data the engine should already know. If anybody has any idea how I could achieve this or something similar, I'd be very grateful.

As an aside, I know I could use Play or Crossfade to work backwards from my logic here, but my contention with that is that I'd have less control of the specifics of each attack's transition. Ideally, I'd like to have specific control how each attack transitions into the next. The animator allows this to happen easily, potentially allowing an animator to fine-tune how transitions, well, transition, all on their own. I'd preferably like to keep that elegance.

If it still isn't clear to you what I'm trying to do, I made a couple short videos to explain the whole thing: https://cdn.discordapp.com/attachments/469139531250008065/626846720738983966/explain1.mp4 https://cdn.discordapp.com/attachments/469139531250008065/626847560618868736/explain2.mp4

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

  • Sort: 
avatar image
0
Best Answer

Answer by Tyooo · Sep 26, 2019 at 09:43 PM

Okay, I feel like a fool. An Index Out of Bounds exception was actually causing my test with AnimatorCondition not to complete and I hadn't noticed. I was totally mistaken - the threshold parameter was exactly what I was looking for. It sends you the value a transition is looking for in its condition. I spent hours wracking myself about this. Gah.

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

209 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

Related Questions

Can't add condition to a transition in animator controller 0 Answers

Set transitions not working with right click in Mac 0 Answers

Animator in child receives float from parent but animation doesn't change when condition is met. 1 Answer

Tweaking screen transitions not to fire every time 0 Answers

Animator not changing states on prefabs 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