- Home /
Super simple Enemy follow player..
Hi all.. im having trouble making from what i know is a super simple thing to do :P make an enemy that tracks to the player.. or follows it.. what is the easiest way to do this? I've created a tag to my player called: "Player" do i track it? how would i do that? and if you could code in C# that would be awesome :D
Answer by koushik.s · Jul 28, 2015 at 05:39 AM
you can use Path finding . void Chasing () { // Create a vector from the enemy to the last sighting of the player. Vector3 sightingDeltaPos = Player.tranform.position- transform.position;
// If the the last personal sighting of the player is not close...
if(sightingDeltaPos.sqrMagnitude > 4f)
// ... set the destination for the NavMeshAgent to the last personal sighting of the player.
nav.destination = enemySight.personalLastSighting;
// Set the appropriate speed for the NavMeshAgent.
nav.speed = chaseSpeed;
}
Your answer
Follow this Question
Related Questions
homing bullets 1 Answer
Enemy tracking Script Help 0 Answers
Enemy follow script without rotation 1 Answer
Problem with 2 scripts communicating 0 Answers
Why is my enemy stopping before it reaches the player? 1 Answer