Hi,
I have read this ( Survival Shooter Training Day Phases - Unity Learn ) but i cant implement it…
I have a StateMachineBehaviour called landing with a public static float Impact;
public class Landing : StateMachineBehaviour {
public static float Impact;
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
PlayerScript.Landing = true;
PlayerScript.currentSpeed = 0;
PlayerScript.jumpSpeed = 0;
Impact = 5;
}
}
now i need to be able to access Impact in my PlayerScript… but I’m finding it impossible to do so…
public class PlayerScript : MonoBehaviour {
private StateMachineBehaviour exampleSmb;
private Animator anim;
void Start ()
{
anim = GetComponent<Animator>();
exampleSmb = anim.GetBehaviour<StateMachineBehaviour>();
}
void FixedUpdate()
{
Debug.Log(exampleSmb.Impact);
}
}
Please help… I know it has to be something simple I’m doing wrong… it doesn’t understand exampleSmb.Impact… I’m referencing it wrong. How do i do this??