An easy one

I’ve been experimenting with this LockOnTarget script. It basicly rotates spawn point so the turret fires at the locked target. Now I want to unlock the target, so I can aim freely, but i don’t know how to set SmoothLookAt.target to None. Please help, I’ve spent hours trying to find an answer on the web.

Here’s the code:

var smoothLookAtScript;
public var targetToLock : Transform;
var targetLocked : boolean;

function Update () {

	if (Input.GetKey (KeyCode.F1)  !targetLocked)
	targetLocked = true;

	if (Input.GetKey (KeyCode.F2)  targetLocked)
	targetLocked = false;
		smoothLookAtScript.target = ???????????;

	if (targetLocked){
	targetToLock = GameObject.FindWithTag("enemy").transform;
	smoothLookAtScript = gameObject.GetComponent(SmoothLookAt);
	smoothLookAtScript.target = targetToLock;
}}

The questionmarks are reflecting my face expression.

Hum…maybe null ?

Nope. Tried null, zero, None and anything I could think of. Kinda like trying to hack a collegue’s screen saver password.

var go : GameObject;

function Awake () {
	go = null;
	Debug.Log (go);
	if (go == null) {
		Debug.Log ("Success");
	}
}

I put a gameObject in the go variable. go = null is suppose to override that. The console shows “Success”. It should be null ?

This worked. Here’s the code:

var smoothLookAtScript;
public var targetToLock : Transform;
var targetLocked : boolean;
public var go : GameObject;

function Update () {

	if (Input.GetKey (KeyCode.F1)  !targetLocked)
	targetLocked = true;

	if (Input.GetKey (KeyCode.F2)  targetLocked)
	targetLocked = false;
		smoothLookAtScript = gameObject.GetComponent(SmoothLookAt);
		go = null;
		smoothLookAtScript.target = go;


	if (targetLocked){
	targetToLock = GameObject.FindWithTag("enemy").transform;
	smoothLookAtScript = gameObject.GetComponent(SmoothLookAt);
	smoothLookAtScript.target = targetToLock;
	
}}

I would never get to this solution.

Thx Akilae!