public override void Execute() { base.Execute(); if (_target) { _npc.MoveTo(_target.transform.position); } else { _target = _npc.target; } }
public override void Execute() { base.Execute(); origin = new Vector3(_npc.transform.position.x, _npc.transform.position.y - _npc.transform.gameObject.GetComponent <MeshFilter>().mesh.bounds.extents.y + 0.5f, _npc.transform.position.z); direction = (new Vector3(_npc.transform.position.x, _npc.transform.position.y - _npc.transform.gameObject.GetComponent <MeshFilter>().mesh.bounds.extents.y + 0.5f, _npc.transform.position.z) - new Vector3(_target.transform.position.x, _target.transform.position.y - _target.transform.gameObject.GetComponent <MeshFilter>().mesh.bounds.extents.y + 0.5f, _target.transform.position.z)).normalized; RaycastHit ray; if (Physics.Raycast(origin, direction, out ray, 500, layerMask)) { if (borderNodes.Contains(ray.collider.gameObject)) { _npc.MoveTo(ray.collider.transform.position); } } }