#pragma strict
function Start () {
}
function Update () {
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player" ){
other.gameObject.GetComponent(EstadoScript).estado = 1;
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player" ){
other.gameObject.GetComponent(EstadoScript).estado = 0;
}
}
#pragma strict
function Start () {
}
function Update () {
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player" ){
other.gameObject.GetComponent(EstadoScript).estado = 2;
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player" ){
other.gameObject.GetComponent(EstadoScript).estado = 1;
}
}
#pragma strict
var estado : int = 0; //estado de inteligencia artificial en el que se encuentra
var vida : float = 100;
var muerto : boolean = false;
var nada : AnimationClip;
var corre : AnimationClip;
var ataca1 : AnimationClip;
var muere : AnimationClip;
var player : Transform;
function Start () {
}
function Update () {
if (estado == 0){
GetComponent.<Animation>().Play (nada.name);
}
if (estado == 1){
GetComponent.<Animation>().Play (corre.name);
transform.LookAt(player);
transform.Translate (Vector3 (0,0,1)*Time.deltaTime);
}
if (estado == 2){
GetComponent.<Animation>().Play (ataca1.name);
}
if (estado == 3){
GetComponent.<Animation>().Play (muere.name);
Destroy (this.gameObject, 2);
}
if (vida <= 0){
muerto = true;
}
if (muerto == true){
estado = 3;
vida = 0;
}
}
function OnTriggerEnter (other : Collider ){
if (other.gameObject.tag == "ManodelPlayer"){
vida -= 20;
}
}
and here is the gameobjects… rango de vision and rango de ataque:
It’s a null error and it tells you what lines in what scripts are null. So figuring it out is looking at the script and seeing what could be null. The line 16 error makes me wonder if your player has the EstadoScript attached to them. I’d check that first.
The other script points to line 41 of a script, but no clue which script it is or what line it is since only the third script goes to 41 and it has nothing on line 41. But, you just need to look at BotControlScript on line 41 and see what could be null on that line.
pd: the nullreference of the botscript i dont care, only care the error the script of rango de vision & ataque, because not leat me continue the game, i mean the game is stopped when this pass :v
if (other.gameObject.tag == "Player" ){
other.gameObject.GetComponent(EstadoScript).estado = 2;
This says to check if the other target is tagged as Player. If they are tagged as Player, find the EstadoScript on them and set the field estado to 2. If there is no EstadoScript on the player, then you get your null error. So whatever the script is attached to is the gameobject you need to target if that is your intent.
Unfortunately I can’t see your setup. I can just tell you why you are getting the null error. Now you need to figure out how to get the EstadoScript. If it’s on the same object that the script with the trigger is on? If so, you just use gameObject.GetComponent. You don’t target other.
now, i want what inside of the script, recognize two specifics collisions. Why want this? because inside of the enemy there are one sphere Collider, and a box collider, so… for what not collision the sphere and the box at same time, i want specify which object will collide with the player