I am attempting to create an enemy (a squirrel that throws nuts) that I can import to a friend’s project. The squirrel itself works fine, but every time I place a new one I have to re-assign the Projectile variable via the inspector. I’ve been trying to get around this with code, but it can only copy an existing object and not the prefab. Am I doing this correctly?
var ProjectileAcorn : GameObject;
function Start(){
ProjectileAcorn = GameObject.Find("Squirrel_Acorn");
}
function Update(){
if(timer==15 && aware == 1)
{
var instanceAcorn = Instantiate(ProjectileAcorn, position, rotation);}}
The nut has a separate script for moving, animating, impact, etc.