How to turn a spawned enemy ( AI ) target on player?/ Why are my Hierarchy object turn prefab then no longer hold the transform object?

Hi all unities,

Why are my Hierarchy object turned to prefab then no longer hold the transform object I set in hierarchy window before, how to turn a spawned enemy ( AI ) targeting on player?

Please show me javascript snippet thanks.


thanks.

have you tried to locate the player with a tag??

I guessed I fixed this particular problem just wondered why the Transform modifier cannot hold the same value as before it become a prefab... But I am done with this at this mean time...

1 Answer

1

I think this should work

var target : GameObject;

function Start(){
    target = GameObject.Find("Player");
}

I got this but thanks anyway.