title: Performance optimisation : null check in Update()
body: <p>I'm currently working on a basic AI for enemies in my space shooter project.
  In my EnemyAI script, I've a <code>public Transform target</code> that I set when I instantiate a enemy. In the Update loop, I'm looking at the target, then moving using <code>transform.towards</code> and everything works fine. The problem is, the <code>target</code> can die, so I need to check if it is not null before doing all that. Problem is : apparently doing a simple <code>if(target == null)</code> is really bad performance wise, and I need to do it in Update. What should be the best approach to achieve that without having performance problems (let say I want 500 enemies at once). Should I still do it every X frame, cache the position of the target till the next check and move toward that cached result ? That could work but it would introduce jitter if the time between two check if too long.</p>
  
  <p>I couldn't find any "easy" way but I hope there is one, it looks like something really simple and it's causing a lot of troubles :/</p>