Hi,
What would be the best way to limit this tracking rotation between 0 - 180 degrees ? I’ve used transform.eulerAngles to get the degrees of the transform and limited it between 0 - 180 but it stays at ether one end or the other.
Thanks.
function trackTarget(){
// Rotate towards target and track it
var targetPoint = target.position;
var targetRotation = Quaternion.LookRotation (targetPoint - transform.position, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * trackSpeed);
if(distanceToPlayer < attackRange){
shoot();
}
}