- Home /
Script error. Please Help!
I have this script:
var speed = 3.0; var rotateSpeed = 3.0; var bullitPrefab:Transform; function Update () { var controller : CharacterController = GetComponent(CharacterController); transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0); var forward = transform.TransformDirection(Vector3.forward); var curSpeed = speed * Input.GetAxis ("Vertical"); controller.SimpleMove(forward * curSpeed); if(Input.GetButtonDown("Jump")) { var bullit = Instantiate(bullitPrefab, GameObject.Find("spawnPoint").Transform.position, Quaternion.identity); bullit.rigidbody.AddForce(transform.forward * 2000);
}
@script RequireComponent(CharacterController);
And I keep getting this error: Assets/Level Prefabs/NewBehaviorScript.js(18,7): BCEOO44: expecting } '@script'.
-What have i done wrong and how can I fix it????
Answer by Jesse Anders · Nov 29, 2010 at 04:01 AM
It looks like your brackets aren't balanced (for every opening curly bracket, you should have a corresponding closing curly bracket).
Answer by Jono 1 · Nov 30, 2010 at 06:41 AM
here is the full wormgame move around script
var speed = 3.0; var rotateSpeed = 3.0; var bullitPrefab:Transform; private var dead = 0;
function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "fallout") { dead = 1; } }
function Update () { var controller : CharacterController = GetComponent(CharacterController); transform.Rotate(0, Input.GetAxis ("Horizontal") rotateSpeed, 0); var forward = transform.TransformDirection(Vector3.forward); var curSpeed = speed Input.GetAxis ("Vertical"); controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown("Jump"))
{
var bullit= Instantiate(bullitPrefab,GameObject.Find("SpawnPoint").transform.position,
Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
}
function LateUpdate()
{
if(dead)
{
transform.position = Vector3(-180.0226,-400.0016,328.2568);
dead = 0;
}
}
@script RequireComponent(CharacterController)
Answer by vetrogames · Feb 17, 2013 at 04:11 PM
heres the var speed = 3.0; var rotateSpeed = 3.0; var bullitPrefab:Transform; private var dead = 0;
function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "fallout") { dead = 1; } }
function Update () { var controller : CharacterController = GetComponent(CharacterController); transform.Rotate(0, Input.GetAxis ("Horizontal") rotateSpeed, 0); var forward = transform.TransformDirection(Vector3.forward); var curSpeed = speed Input.GetAxis ("Vertical"); controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown("Jump"))
{
var bullit= Instantiate(bullitPrefab,GameObject.Find("SpawnPoint").transform.position,
Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
}
function LateUpdate()
{
if(dead)
{
transform.position = Vector3(-180.0226,-400.0016,328.2568);
dead = 0;
}
}
Your answer
Follow this Question
Related Questions
BCE0044 error: OnControllerColliderHit 2 Answers
(10,47): BCE0044: expecting :, found '='. 2 Answers
BCE0044: expecting :, found '=' 2 Answers
script error GUI super simple code 3 Answers