Goal: Create enemy (turret) behavior that uses all the vector operations covered: Distance, Lerp, Dot Product, and Cross Product.
- A Turret (object A) with its forward direction
transform.forward. - A Player (object B) moving around the scene.
The turret starts "asleep". As soon as the player comes within 10 units, the turret activates (starts working).
Use: Vector3.Distance
The turret should not rotate instantly. It should smoothly rotate toward the player at a speed of rotationSpeed = 120° per second.
Use: Quaternion.LookRotation + Quaternion.RotateTowards or Vector3.Lerp for direction.
The turret only fires when the player is within a 90° sector in front of the turret
(i.e., the angle between the turret's forward direction and the direction to the player is less than 45° on each side → dot > 0.7).
Use: Vector3.Dot
In debug mode, log to the console whether the player is to the left or to the right of the turret.
Use: Vector3.Cross
If the turret is activated, the player is within the field of view (dot > 0.7), and the distance is < 10 → every 1 second, log "Pew! Pew!" to the console.
Make a projectile move smoothly from the turret to the player's position using Vector3.Lerp.
You will write a script that demonstrates an understanding of all five vector operations working together. The turret reacts naturally, without sharp rotations, and only fires within the forward-facing sector.
Turret.cs- Movement for Player can be taken from
04-MonoBehaviourtopic. ->PlayerMovement.cs