- Home /
How to fix this animator is not playing an animatorcontroller?
How do I fix this warning sign that keeps popping up in Unity.
My code is
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;
}
}
}
Answer by AWilliams5 · Mar 19, 2019 at 07:56 PM
I also would like to know how to program an AI fighter. I have been following this guy for my code and AI https://www.youtube.com/watch?v=IR437gsoG-M∈dex=20&list=PLO8VSSi-HMWTpBk7WIEL_iVfyQLebqtiJ
but when I type in the code for the AI, the controller stopped working and all I could do was walk forward and eventually got to the point where I couldn't move at all.
Your answer
Follow this Question
Related Questions
[Resolved]Animator.Rebind on instantiated child. 0 Answers
Running animation 1 Answer
animation control problem 0 Answers
teleporter not working due to animator 0 Answers
Have some minor problems. Cant tell if its a script issue or a animator issue. 1 Answer