Has anyone tried the Michelle Menard Game Development with Unity book?
The first script I’ve tried is buggy and I can’t figure if I’ve done something wrong or why I’m getting this error: “Unexpected token : true” for the variable: “private var outsideRange : true;”
Also the public variables aren’t showing up in the Inspector so I can’t assign the prefab.
Here is the script, if anyone can tell me if it’s me or Michelle that would be great! Thanks.
#pragma strict
//attach to a GameObject to serve as respawn point when the player walks within range
var spawnRange = 40.0;
var enemy : GameObject;
private var target : Transform;
private var currentEnemy : GameObject;
private var outsideRange : true;
private var distanceToPlayer;
function Start ()
{
target = GameObject.FindWithTag(“Player”).transform;
}
function Update ()
{
distanceToPlayer = transform.position - target.position;
if (distanceToPlayer.magnitude < spawnRange)
{
if (!currentEnemy)
{
currentEnemy = Instantiate(enemy, transform.position, transform.rotation);
}
}
else
{
if (currentEnemy)
Destroy(currentEnemy);
}
outsideRange = true;
}
@script AddComponentMenu (“Enemies/Respawn Point”)