- Home /
Unexcpected Token error with transform.find
The console keeps giving me an error(Unexpected token: fireLocation)
I am trying to find the child object called fire Loc where the bullet prefab will be instantiated. The SetValues function is called on function start.
I included most of the code just incase.
class Weapon extends Item{
var range : float;
var rateOfFire : int;
var weaponType : weaponType;
var clipSize : int;
var fireLocation : GameObject;
var bulletPrefab : ammoType;
private var AmmoDatabase : GameObject; //Holds the prefabs for the the bullets.
function SetValues(){
ammoDataBase = GameObject.Find("GlobalAmmoDataBase"); // This line works fine
Debug.Log(gWeaponManager.name);
fireLocation : Transform = GameObject.transform.Find("fireLoc"); //This is where the error is
}
Answer by markpdolby · Jul 02, 2013 at 10:47 PM
You have declared fireLocation twice, try changing the name of either of them to something else and see if that fixes your problem. Or change:
fireLocation : Transform = GameObject.transform.Find("fireLoc");
to fireLocation = GameObject.transform.Find("fireLoc");
Answer by KiraSensei · Jul 02, 2013 at 10:48 PM
var fireLocation2 : Transform = GameObject.transform.Find("fireLoc");
Your answer
Follow this Question
Related Questions
Why do i get an EOF error? 2 Answers
NullReferenceException yet Debug.Log shows nothing is null? 1 Answer
Unexpected token: .. 1 Answer
Argument out of range - Generic list (JS) 2 Answers
Public Class Error 1 Answer