get this error Assets/PlayerDecection.cs(12,33): error CS1061: Type `AnimalAI' does not contain a definition for `Player' and no extension method `Player' of type `AnimalAI' could be found (are you missing a using directive or an assembly reference?)
this is my code:
using UnityEngine; using System.Collections;
public class PlayerDecection : MonoBehaviour {
 public AnimalAI AIMotor;
 public AudioClip SFX;
 void OnTriggerEnter (Collider col)
 {
 if(col.tag == "Player")
 {
         AIMotor.Player = col.gameObject;
         AIMotor.PlayerOnSight = true;
         GetComponent<AudioSource>().PlayOneShot(SFX);
     
     }
 }
 void OnTriggerExit (Collider col)
 {
     if(col.tag == "Player")
     {
         AIMotor.Player = null;
         AIMotor.PlayerOnSight = false;
         GetComponent<AudioSource>().Stop();
         
     }
 }
}
viewing the text on this site, the errors are on line 7 and 18
As the error says in the Script AnimalAI you don't have a definition of Player. Without seeing the script it's hard to tell.
@Postive7 using UnityEngine; using System.Collections;
public class PlayerDecection : $$anonymous$$onoBehaviour {
 public AnimalAI AI$$anonymous$$otor;
 public AudioClip SFX;
 void OnTriggerEnter (Collider col)
 {
 if(col.tag == "Player")
 {
         AI$$anonymous$$otor.Player = col.gameObject; // error here
         AI$$anonymous$$otor.PlayerOnSight = true;
         GetComponent<AudioSource>().PlayOneShot(SFX);
     
     }
 }
 void OnTriggerExit (Collider col)
 {
     if(col.tag == "Player")
     {
         AI$$anonymous$$otor.Player = null;  // error here
         AI$$anonymous$$otor.PlayerOnSight = false;
         GetComponent<AudioSource>().Stop();
         
     }
 }
}
using UnityEngine; using System.Collections;
public class AnimalAI : $$anonymous$$onoBehaviour {
 public Transform[] Waypoints;
 public int NextDest = 0;
 private Nav$$anonymous$$eshAgent agent;
 public bool PlayerOnSight;
 void Start () {
     agent = GetComponent<Nav$$anonymous$$eshAgent> ();
 }
 
 // Update is called once per frame
 void Update () {
     if (!PlayerOnSight) {
         if (agent.remainingDistance < 0.5f) {
             agent.SetDestination (Waypoints [NextDest].position);
             NextDest = (NextDest + 1) % Waypoints.Length;
         }
         
         if (agent.remainingDistance > 0.5f) {
             GetComponent<Animation> ().Play ("Horse_Walk");
         }
         if (GetComponent<Animation> ().IsPlaying ("Horse_Walk")) {
             agent.speed = 4f;
         }
     
     
     } 
     else if (PlayerOnSight) 
     {
         Vector3 Direction2Player;
         if (agent.remainingDistance > 0.5f) {
             GetComponent<Animation> ().Play ("Horse_Run");
         }
         if (GetComponent<Animation> ().IsPlaying ("Horse_Run")) {
             agent.speed = 8f;
         }
     }
Your answer
 
 
             Follow this Question
Related Questions
There is no button in animation tap... 0 Answers
how to randomly generate number with out using a number twice 2 Answers
How can I solve this error? 1 Answer
C# Setting AudioMixerGroup through code 2 Answers
How to make a base building game 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                