Created
January 23, 2020 02:48
-
-
Save thelebaron/efe80e3337e205115e54443512ba0480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Animancer; | |
using UnityEngine; | |
public class Dude : MonoBehaviour | |
{ | |
[SerializeField] private LinearMixerState.Transition GroundedMixerTransitionBase; | |
private LinearMixerState GroundedMixerState; | |
[SerializeField] private LinearMixerState.Transition PainMixerTransitionBase; | |
private LinearMixerState PainMixerState; | |
private AnimancerComponent animancer; | |
public bool PlayPain; | |
public bool PlayGrounded; | |
void Start() | |
{ | |
animancer = GetComponent<AnimancerComponent>(); | |
GroundedMixerState = (LinearMixerState) animancer.States.GetOrCreate(GroundedMixerTransitionBase); | |
PainMixerState = (LinearMixerState) animancer.States.GetOrCreate(PainMixerTransitionBase); | |
PainMixerState.Parameter = 1; | |
animancer.Play(PainMixerTransitionBase); | |
} | |
public void PlayGroundedState() | |
{ | |
GroundedMixerState.Parameter = 1; | |
animancer.Play(GroundedMixerState); | |
} | |
public void PlayPainState() | |
{ | |
PainMixerState.Parameter = 1; | |
animancer.Play(PainMixerState); | |
} | |
public void Update() | |
{ | |
if (PlayGrounded) | |
PlayGroundedState(); | |
if (PlayPain) | |
PlayPainState(); | |
PlayPain = false; | |
PlayGrounded = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment