void Start() { fov = new GameObject("FOV"); fov.AddComponent <FiledOfView>(); fov.AddComponent <MeshRenderer>(); MeshRenderer fovMeshRenderer = fov.GetComponent <MeshRenderer>(); fov.AddComponent <MeshFilter>(); Material fovMaterial = Resources.Load("Vision", typeof(Material)) as Material; fovMeshRenderer.material = fovMaterial; fv = fov.GetComponent <FiledOfView>(); fv.parent = gameObject; fv.ghost = GetComponentInChildren <CollectEnemy>().ghost; animator = gameObject.GetComponent <Animator>(); body = gameObject.GetComponent <Rigidbody2D>(); randomSpot = Random.Range(0, fixedSpots.Count); currentWaitTime = waitTime; aim = Vector3.zero; }
private void Awake() { animator = GetComponent <Animator>(); rb = GetComponent <Rigidbody>(); fov = GetComponentInChildren <FiledOfView>(); fov.OnPlayerEnter += CheckIfPlayerVisible; audiosource = GetComponent <AudioSource>(); transform.position = grid.CellToLocal(grid.LocalToCell(transform.position)); }