Question by
AWilliams5 · Mar 24, 2019 at 06:19 PM ·
c#animationanimator
I'm having an issue where Unity gives me this warning that says (animator is not playing an animatorcontroller
Hi, starting with the second question. I'm having an issue where Unity gives me this warning that says (animator is not playing an animatorcontroller) Here is the Code I used for my Player_Controller
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Fighter_Player : MonoBehaviour { public enum PlayerType { HUMAN, AI }
public static float MAX_HEALTH = 100F;
public float healt = MAX_HEALTH;
public string fighterName;
public Fighter_Player oponent;
public PlayerType player;
protected Animator Player;
private Rigidbody myBody;
// Use this for initialization
void Start () {
myBody = GetComponent<Rigidbody> ();
Player = GetComponent<Animator> ();
}
public void UpdateHumanInput () {
if (Input.GetAxis ("Horizontal") > 0.1) {
Player.SetBool ("Walk_Forward", true);
} else {
Player.SetBool ("Walk_Forward", false);
}
if (Input.GetAxis ("Horizontal") < -0.1) {
Player.SetBool ("Walk_Backward", true);
} else {
Player.SetBool ("Walk_Backward", false);
}
if (Input.GetAxis ("Vertical") < -0.1) {
Player.SetBool ("Duck", true);
} else {
Player.SetBool ("Duck", false);
}
if (Input.GetKeyDown (KeyCode.F)) {
Player.SetTrigger ("Punch_Mid");
}
if (Input.GetKeyDown (KeyCode.G)) {
Player.SetTrigger ("Special_Move");
}
}
// Update is called once per frame
void Update () {
Player.SetFloat ("health", healtPercent);
if (oponent != null) {
Player.SetFloat ("oponent_health", oponent.healtPercent);
} else {
Player.SetFloat ("oponent_health", 1);
}
if (player == PlayerType.HUMAN) {
UpdateHumanInput ();
}
}
public float healtPercent {
get {
return healt / MAX_HEALTH;
}
}
public Rigidbody body {
get {
return this.myBody;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Having problems with making a Navmesh Agent stop and play an attack animation 0 Answers
Trying to change an animation with a UI button 2 Answers
Animator transition not working on parameter 0 Answers
Unassigned Reference Exception 0 Answers
How to add programatically animationClips to one animation from Resources folder? 0 Answers