Where to put the =null

I’m working on the extended space shooter, and a question at the end asked about making homing enemy ships, which sounded interested, so filling in the code gave the null error as seen in the video.

(Unity Connect) (At around 1 hour 55 minutes).

However, I don’t know what to do after/where to place the if (playerTransform = null)

I have the ‘homing’ code //'d out.

Any help would be great, thanks!

using UnityEngine;
using System.Collections;

public class PlasmaHomer : MonoBehaviour
{

	public float dodge;
	public float smoothing;
	public float tilt;
	public Vector2 startWait;
	public Vector2 maneuverTime;
	public Vector2 maneuverWait;
	public Boundary boundary;

	//private Transform playerTransform;
	private float currentSpeed;
	private float targetManeuver;
	private Rigidbody rb;

	void Start ()
	{
		rb = GetComponent <Rigidbody> ();
		//playerTransform = GameObject.FindGameObjectWithTag ("Player").transform;
		currentSpeed = rb.velocity.z;
		StartCoroutine (Evade ());
	}

	IEnumerator Evade()
	{
		yield return new WaitForSeconds (Random.Range (startWait.x, startWait.y));

		while (true)
		{
			targetManeuver = Random.Range (1, dodge) * -Mathf.Sign (transform.position.x);
			//targetManeuver = playerTransform.position.x;
			yield return new WaitForSeconds (Random.Range (maneuverTime.x, maneuverTime.y));
			targetManeuver = 0;
			yield return new WaitForSeconds (Random.Range (maneuverWait.x, maneuverWait.y));
		}
	}

	void FixedUpdate ()
	{
		float newManeuver = Mathf.MoveTowards (rb.velocity.x, targetManeuver, Time.deltaTime * smoothing);
		rb.velocity = new Vector3 (newManeuver, 0.0f, currentSpeed);
		rb.position = new Vector3 
			(
				Mathf.Clamp (rb.position.x, boundary.xMin, boundary.xMax),
				0.0f,
				Mathf.Clamp (rb.position.z, boundary.zMin, boundary.zMax)
			);

		rb.rotation = Quaternion.Euler (0.0f, 0.0f, rb.velocity.x * -tilt);
	}
}

playerTransform = null

That means that you are setting the playerTransform to equal null.

playerTransform == null

That means you are checking if the playerTransform is equal to null.

Check out this list of operators for more information.