Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CrossFadeInFixedTime equivilent for state machine. #2252

Open
Muzz opened this issue Feb 16, 2024 · 3 comments
Open

Add CrossFadeInFixedTime equivilent for state machine. #2252

Muzz opened this issue Feb 16, 2024 · 3 comments
Labels
animations suggestion Idea or improvement suggestion
Milestone

Comments

@Muzz
Copy link
Contributor

Muzz commented Feb 16, 2024

Issue description:
The state machine while powerful, is limiting to only use the arrows to handle transitions.

Instead what we would like is function like unities CrossFadeInFixedTime function, to allow us to directly set which state we are going to from code.

It might already be possible, if not, i'll probably try and hack it in myself, and do a pull request.

for reference for what We're looking for.
https://docs.unity3d.com/ScriptReference/Animator.CrossFadeInFixedTime.html

@mafiesto4 mafiesto4 added suggestion Idea or improvement suggestion animations labels Feb 17, 2024
@Muzz
Copy link
Contributor Author

Muzz commented Feb 27, 2024

Ok, so we're heavily blocked with improving our character controller until we do this, we have so many states that need to have their transitions modified by code ect that the current setup isn't viable, also the lack of transparency of what's happening under the hood of the transition system in dev makes the systems very difficult to debug.

I'm looking into how to do it, but it seems to be very clunky with how things are setup.

The approaches I'm looking to try is using a similar approach to the virtual one shot animation function, and create a virtual transition and discard it once it's fired. But that has complications as i would need to have a way of specifying what node is the state machine, then building the transition and firing it.

I'm happy to spend a few days implementing this, but i'll need guidance on the best way to do it, as i don't fully understand what's going on under the hood, and there isn't many examples of doing something like this in the code base to work from.

We can't afford to wait on this feature though, hence why i need to work on it.

@mafiesto4 mafiesto4 added this to the 1.9 milestone Feb 27, 2024
@mafiesto4
Copy link
Member

Have you tried using a structure passed to the graph with all transitions - I'm aware there might be a lot states required to handle but with Any state you can create only a single transition to each state. https://docs.flaxengine.com/manual/animation/anim-graph/state-machine.html#any-state

public struct MyTransitions
{
    public bool Idle;
    public bool Run;
    public bool Walk;
}

We could implement a similar API to enforce the state via API call (via AnimatedModel that owns AnimGraphInstanceData and can write custom data there for this feature) but it breaks the (simplicity of) design of Anim Graph.

@Muzz
Copy link
Contributor Author

Muzz commented Feb 27, 2024

Thanks for replying!

Setting the parameters to switch states isn't the issue, we just use an int to do that which is very easy, just one param.

The any state node will help things a lot once it's fixed, but that doesn't get around the issue of programmatically setting the transition settings, we can't pass these in as params. And if we can get a way to programmatically change the properties of the transition, we're not using the utility of having a transition graph.

There are many times where we want to transition into a state faster given a set of circumstances, and it would be much better to have this be dynamic.

Being able to just call change state in code with the settings we want, would greatly simplify our system and prevent us needing to replicate our characters state transitions within the anim graph.

@mafiesto4 mafiesto4 modified the milestones: 1.9, Future Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
animations suggestion Idea or improvement suggestion
Projects
None yet
Development

No branches or pull requests

2 participants