Help with annoying thing pleaaaase!!!

OK so ive been at it for hours but still can fix it, ive tried monodevelop to typing the whole thing again but stupid errors are still there!! theres my code heres my errors (12,10): BCE0044: expecting (, found ‘OnTriggerEnter’
(12,29): BCE0044: expecting ), found ‘:’ (12,31): BCE0044: expecting :, found ‘Collider’

Sorry for my messy script :smile:

var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab:Transform;
static var dead = false; 
var tumbleSpeed = 800;
var decreaseTime = 0.01;
var decayTime = 0.01;
static var gotHit = false;
private var backup = [tumbleSpeed, decreaseTime, decayTime];
{
function OnTriggerEnter(hit : Collider)
}
function LateUpdate()
{
if(dead)
{
transform.position = Vector3(0,4,0);
gameObject.Find("Main Camera").transform.position = Vector3(0,4,-10);
dead = false;
}
}

if(gotHit)
{
if(tumbleSpeed < 1)
{
tumbleSpeed = backup[0];
decreaseTime = backup[1];
decayTime = backup[2];
gotHit = false;
}
else
{

transform.Rotate(0,tumbleSpeed*Time.deltaTime,0, Space.World);
tumbleSpeed = tumbleSpeed-decreaseTime;
decreaseTime += decayTime;
}
{
if(hit.gameObject.tag == "fallout")
{
dead = true;
HealthControl.LIVES -= 1;
}
if(hit.gameObject.tag == "enemyProjectile")
{
gotHit = true;
HealthControl.HITS += 1;
Destroy(hit.gameObject);
}
}

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, 
transform.Find("spawnpoint").transform.position, 
Quaternion.identity);
bullit.tag = "wormProjectile";	
bullit.rigidbody.AddForce(transform.forward * 2000);
}
}

@script RequireComponent(CharacterController)

i believe function OnTriggerEnter(hit : Collider) should be one line higher

It looks like your Open bracket needs to be after the OnTriggerEnter(hit : Collider) { //Like so

}

This should’ve fixed your errors. now you just need to declare what health control is.

var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab:Transform;
static var dead = false; 
var tumbleSpeed = 800;
var decreaseTime = 0.01;
var decayTime = 0.01;
static var gotHit = false;
private var backup = [tumbleSpeed, decreaseTime, decayTime];

function OnTriggerEnter(hit : Collider) {
		if (hit.gameObject.tag == "fallout") {
		dead = true;
		HealthControl.LIVES -= 1;
}
		if(hit.gameObject.tag == "enemyProjectile") {
			
		gotHit = true;
		HealthControl.HITS += 1;
		Destroy(hit.gameObject);
	}
}

function LateUpdate()
{
	if(dead) {
	
		transform.position = Vector3(0,4,0);
		gameObject.Find("Main Camera").transform.position = 						Vector3(0,4,-10);
		dead = false;
}

	if(gotHit) {
	
	if(tumbleSpeed < 1) {
		
		tumbleSpeed = backup[0];
		decreaseTime = backup[1];
		decayTime = backup[2];
		gotHit = false;
}

	else {

		transform.Rotate(0,tumbleSpeed*Time.deltaTime,0, Space.World);
		tumbleSpeed = tumbleSpeed-decreaseTime;
		decreaseTime += decayTime;
		}
	}
}

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, 
transform.Find("spawnpoint").transform.position, 
Quaternion.identity);
bullit.tag = "wormProjectile";	
bullit.rigidbody.AddForce(transform.forward * 2000);
}
}

@script RequireComponent(CharacterController)

There were multiple problems. There were not enough closing brackets, you had an extra open bracket above function ontriggerenter, you were trying to call your “hit” outside of your ontriggerenter function, and the one you still need to fix is declaring what HealthControl is

Could you please explain in more detail “There were not enough closing brackets” im not very experienced with this sort of thing, thanks

private var backup = [tumbleSpeed, decreaseTime, decayTime];
{
function OnTriggerEnter(hit : Collider)
}

should be

private var backup = [tumbleSpeed, decreaseTime, decayTime];
function OnTriggerEnter(hit : Collider) { // function start
/// code here
} // function end

I suggest you look at some of the many scripts available to see how vars and function are defined in scripting

Ooooommmmggggg thank you all espescially airmand i love you 7 hours later and your code worked hahaha finally i can continue with lvl 3

{ - opening bracket obviously
} - closing bracket obviously

every “{” used in your functions and in your if and else statements need a “}” . Also, these brackets cannot be used outside of functions like above your ontriggerenter function you have an { that shouldnt be there. In your script, you had more “{” than “}”. Also im guessing that your HealthControl is a variable inside of another script. If so, you need to either use GetComponent, or make HealthControl a static variable and when you call HealthControl in the script you posted you would need to type script.HealthControl. If health control is an object in your scene, you could just put var HealthControl : GameObject;
Hopefully this explains it better.

Glad to help a fellow noob scripter. I myself started learning how to script 6 months ago. It was a slow start but im really learning to love it. And im glad to know i helped.

http://forum.unity3d.com/threads/96572-How-to-use-verbose-title-and-content-to-get-the-help-you-want-when-posting-a-thread.