I have a javascript that runs an automatic turret… it controls the movement of the turret and a light that changes color depending if thee turret is engaged or not. Problem is the turret looks about 45 degrees to the right of the player. This has happened with a lot of scripts now and I have tried resetting various coordinates such as rotation of the turret, and the turret head and the player. Here’s the code;
var range : float = 75; var target : Transform; var damp : float = 2.5; var indicator : Light; function Update () { target = GameObject.FindWithTag("Player").transform; var distance = Vector3.Distance(target.transform.position, transform.position); if(distance <= range) { indicator.light.color = Color.red; if(target) { var rotate = Quaternion.LookRotation(target.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp); transform.LookAt(target); } } if(distance >= range) { indicator.light.color = Color.green; } } ` How can I make it look about 45 degrees further to the left (or right, depending which way you look at it)? `