Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Transform sight;
- void OnDrawGizmos() {
- Gizmos.DrawWireSphere(transform.position, AgroRange);
- Gizmos.DrawWireSphere(transform.position, TrackRange);
- if (!sight)
- sight = transform.FindChild("Sight");
- Gizmos.DrawLine(sight.position, TranslatePos(sight.position, sight.eulerAngles.y+135,20, AgroRange));
- Gizmos.DrawLine(sight.position, TranslatePos(sight.position, sight.eulerAngles.y+225,20, AgroRange));
- Gizmos.DrawLine(sight.position, TranslatePos(sight.position, sight.eulerAngles.y+135,-20, AgroRange));
- Gizmos.DrawLine(sight.position, TranslatePos(sight.position, sight.eulerAngles.y+225,-20, AgroRange));
- if (targets.Count > 0)
- Gizmos.DrawLine(transform.position, targets[0].position);
- }
- Vector3 TranslatePos(Vector3 position, float yaw, float pitch, float dist) {
- Vector3 tmp = Vector3.zero;
- float t = (float)(dist * Mathf.Cos(ToRadian(pitch)));
- tmp.y = (float)(dist * Mathf.Sin(ToRadian(pitch)) + position.y);
- tmp.x = (float)(t * Mathf.Sin(ToRadian(yaw)) + position.x);
- //tmp.Y = (float)this.pos.Y;
- tmp.z = (float)(t * Mathf.Cos(ToRadian(yaw)) + position.z);
- return tmp;
- }
- float ToRadian(float angle)
- {
- return 3.14f * angle / 180.0f;
- }
Advertisement
Add Comment
Please, Sign In to add comment