|
So I have a spawn script that uses instantiate to spawn an enemy prefab. However the AI script on the enemy uses the position of the player within the hierarchy and instantiated prefabs do not keep these variables. does anybody have any advice on how to create an ai script that doesn't use this but still moves towards the player?
(comments are locked)
|
|
If your player object has a tag, you can use to get the first found object with that tag. If you are using the "Player" tag, and make sure that there is only ever one object with it, it should work fine. Thanks alot, so you think like var player : GameObject; var playerPosition : Vector3; function Update (){ player = GameObject.FindWithTag(Player); playerPosition = player.transform.position; ?
Jan 31 '12 at 05:00 PM
simonheartscake
This worked great. Thanks
Jan 31 '12 at 06:06 PM
simonheartscake
(comments are locked)
|
