Making an Enemy Detect and Follow the Player in Unity - Part 1

Weisbrod Imaging
Weisbrod Imaging
15.2 هزار بار بازدید - 8 سال پیش - This demo goes over how
This demo goes over how to make an Enemy object detect the player and the turn and "attack" the player.

NOTE:  In order to keep from having to drag the FPSController to every instance of the Enemy Prefab, I added the following code:

First, I changed the Player variable to a private variable, so:

"private var Player : Transform"

Then, in the Awake function, I added this line of code:

"Player = GameObject.FindGameObjectWithTag("Player").transform;"

Now, just make sure that you have your Player object tagged as "Player" and everything should work just fine!
8 سال پیش در تاریخ 1395/02/07 منتشر شده است.
15,213 بـار بازدید شده
... بیشتر