Is rotation is close enough to shoot?

Hi Community!

I have a turret that is rotating to the enemy.
Now i want to check, if the current rotation is “looking close enough” to the enemy that the turret can shoot.

I rotate like this:

Vector3 lookPos = enemy.transform.position - this.transform.position;
Quaternion targetRotation = Quaternion.LookRotation(lookPos);
this.transform.rotation = Quaternion.Slerp(this.transform.rotation, targetRotation, Time.deltaTime * RotationSpeed);

How i check now, if the rotation is close enough to the target, that it “can shoot”?
(it does not need to rotate 100% in the right direction, to shoot, maybe 5% diffrence is ok)


use a Raycast or Spherecast from the gun in its forward direction.

Oh man, you are the best!

Thanks for jog my memory :slight_smile:
I will do it with a raycast now.