Hi everybody i am developing a game, the game is about escaping from the jail.
My problem is that i have an script called hide. where it will register if player comes inside the area, and i have another script called Catched that has a boolean to turn true. My problem is that when i use the hide script with one game object it works but using the hide script with multiple gameobjects it only registers with the last gameobject added to the game.
using UnityEngine;
using System.Collections;
using UnityEngine.Assertions.Must;
public class Hide : MonoBehaviour {
public Transform[] HideCast;
public Catched catcher;
// Use this for initialization
void Start () {
}
public void Update()
{
Debug.DrawLine(gameObject.transform.position, HideCast[0].position, Color.red);
Debug.DrawLine(gameObject.transform.position, HideCast[1].position, Color.red);
Debug.DrawLine(HideCast[1].position, HideCast[0].position, Color.red);
catcher.hider = Physics2D.Linecast(gameObject.transform.localPosition, HideCast[0].position, 1 << LayerMask.NameToLayer("Player"))
|| Physics2D.Linecast(gameObject.transform.localPosition, HideCast[1].position, 1 << LayerMask.NameToLayer("Player"))
|| Physics2D.Linecast(HideCast[1].position, HideCast[0].position, 1 << LayerMask.NameToLayer("Player"));
}
}
Sorry for bad english
Hope you guys can help me.
Best Regards Fatih Karaman