- Home /
Question by
fl4shb4ck1992 · Mar 07, 2012 at 10:10 AM ·
issuejavaissues
expecting :, found '=' in checkpoint script
Hey everyone. I'm having a weird issue with my checkpoint script. In the transform.position = vector3 command it continues to tell me I need to replace the = with : ... This is really getting on my nerves. I've looked through the script over and over but am lost with it. Any help would be much appreciated.
private var originalSpawn : boolean = true;
private var respawn2 : boolean;
private var respawn1 : boolean;
function OnTriggerEnter(hit : Collider)
enter code here
{
if (other.gameObject.tag == "Checkpoint1")
{
originalSpawn = false;
respawn1 = true;
respawn2 = false;
}
if (respawn1 == true)
{
{
transform.position = Vector3(187.2115, 15.21173, 158.192);
}
}
if (other.gameObject.tag == "Checkpoint2")
{
originalSpawn = false;
respawn2 = true;
respawn1 = false;
}
if (respawn2 == true)
{
{
transform.position = Vector3(187.2115, 15.21173, 14.37813);
}
}
}
Comment
Best Answer
Answer by Kleptomaniac · Mar 07, 2012 at 11:23 AM
Hey there, just quickly pointing out a problem with your formatting in UA ...
function OnTriggerEnter(hit : Collider)
enter code here
{
Just saying ...
Anyway, aside from that. The problem was you were inserting extra braces around the two transform.position = Vector3(187.2115, 15.21173, 14.37813);
lines, messing up your function and confusing the compiler. Here's the script sans extra braces and enter code here
:
private var originalSpawn : boolean = true;
private var respawn2 : boolean;
private var respawn1 : boolean;
function OnTriggerEnter(hit : Collider)
{
if (other.gameObject.tag == "Checkpoint1")
{
originalSpawn = false;
respawn1 = true;
respawn2 = false;
}
if (respawn1 == true)
{
transform.position = Vector3(187.2115, 15.21173, 158.192);
}
if (other.gameObject.tag == "Checkpoint2")
{
originalSpawn = false;
respawn2 = true;
respawn1 = false;
}
if (respawn2 == true)
{
transform.position = Vector3(187.2115, 15.21173, 14.37813);
}
}
Good luck with your game! Klep
Your answer
![](https://koobas.hobune.stream/wayback/20220613064838im_/https://answers.unity.com/themes/thub/images/avi.jpg)