- Home /
custom function syntax error
I know I'll probably feel stupid when someone tells me what I did wrong. I made a custom respawn function to save from the hassle of destroying and intantiating. When I run it, I get the following error:
Assets/weaponSpawn.js(32,10): BCE0044: expecting (, found 'Respawn'.
Any ideas? I have no clue. I know there is NOT supposed to be a "(" in the name of a Function. Here's my code:
var trashCanWeapon: GameObject; /*var target: Transform;*/ var moveSpeed=10; function Update () { transform.LookAt (target.transform); } function Awake(){
pickupActive=true; renderer.enabled=false; transform.Translate(Vector3(Random.Range(30,-30),0,Random.Range(30,-30))); renderer.enabled=true; }
function OnTriggerEnter(){ var weaponID= (Random.Range(1,1)); if (weaponID==1&&pickupActive==true){ Instantiate (creationFlash, transform.position, transform.rotation); Instantiate (creationFlash, transform.position, transform.rotation); renderer.enabled=false; /if (weaponID==1&&pickupActive==true){/ Instantiate(trashCanWeapon, transform.position, transform.rotation); pickupActive=false; Respawn (); /transform.Translate(Vector3.forward*moveSpeed*Time.deltaTime);/
/Transform.LookAt (target.transform);/ /Destroy (gameObject);/ } function Respawn () { transform.position=GameObject.Find("itemSpawnGenerator").transform.position; transform.Translate(Vector3(Random.Range(30,-30),0,Random.Range(30,-30))); renderer.enabled=true; pickupActive=true; }
As usual, any help would be much appreciated. Thanks guys.
Answer by Eric5h5 · Mar 28, 2011 at 07:08 AM
This is why it's important to format your code properly, and indent where needed. Once you clean it up you'll see where the missing "}" is instantly. See here for some discussion of various indent styles.
Thanks, this is actually my first foray into any kind of program$$anonymous$$g. Until now, all I did was model for a hobby but I think I found something I really like. Just need practice and less of these stupid mistakes will happen lol. Thanks again.