Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CastRays() {
- numRays = fovAngle * quality;
- int facingAngle = fovAngle;
- var dir = actor.facingVector.ToDirection ();
- switch (dir) {
- case Direction.Up:
- break;
- case Direction.Left:
- facingAngle += 2*90;
- break;
- case Direction.Down:
- facingAngle += 2*180;
- break;
- case Direction.Right:
- facingAngle += 2*270;
- break;
- }
- currentAngle = facingAngle / -2;
- hits.Clear();
- for (int i = 0; i < numRays; i++) {
- direction = Quaternion.AngleAxis(currentAngle, -1*transform.forward) * transform.up;
- hit = new RaycastHit();
- if(Physics.Raycast(transform.position, direction, out hit, fovMaxDistance, cullingMask) == false) {
- hit.point = transform.position + (direction * fovMaxDistance);
- }
- hits.Add(hit);
- currentAngle += 1f / quality;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement