- Home /
Ignoring Vector3.MoveTowards()
I have a method which skips over Vector3.MoveTowards() and does the next line instead.
public void EngageHostile()
{
float step = speed * Time.deltaTime;
player.transform.position = Vector3.MoveTowards(player.transform.position, enemyUnit.transform.position, step);
player.transform.renderer.material.color = Color.red;
//Distances
float attackDistance = Vector3.Distance(player.transform.position, enemyUnit.transform.position);
if(attackDistance <= 2.0f)
{
transform.LookAt(enemyToFocus);
}
}
What it does right is that it changes the colour of my player to red when I right click my enemy. What it doesn't do is it doesn't do anything else!
Would be great if you could help :)
Comment
I doubt it skipped the line. You would get this behavior if 'speed' was 0.0. Check the value of 'speed' in the Inspector.