- Home /
 
 
               Question by 
               AWilliams5 · Mar 11, 2019 at 05:11 PM · 
                fightingame  
              
 
              How to make an AI and Player code for a fighting game similar to tekken or street fighter?
Hey i'm having trouble making a code for my player right now. Everything works and responds but I keep getting the warning that the (Animator is not playing an AnimatorController)
Here is my code
**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;
     }
 }
 
               }**
I've looking though it up and down and I can't find anything that's causing the problem. It freezes my animation but the trigger still reacts when I play it but I have to press the button again to cancel the animation. Can anyone please help? I need this for senior thesis.
               Comment
              
 
               
              Your answer