Sunday, August 21, 2016

Mutant aliens

When an alien takes a sheep up to the top of the screen it shears the sheep and becomes a fast moving alien mutant. 
What I want is for the mutants to go after the player. To do that we subtract the 2 positions vectors, giving us the difference between the 2 points. I wanted to use that to then set the direction of the mutant. I discovered there is a function normalized that does just that, so here is the code from the FixedUpdate() to do that. By placing it in the FixedUpdate it will continually change course towards the player.

if (IsMutant)
    var delta = player.transform.position - transform.position;
    direction = delta.normalized;


Aliens take sheep to top then change into Mutants