- Home /
Question by
WeienJune · Oct 30, 2014 at 03:21 AM ·
bullettimer-scriptflagged-for-delete
Coding Error
Completely new to programming....no idea why this java script is wrong...I believe I just copied it from a tutorial video.
This script is for a player in a shooting game, allowing the player to move and send out bullet.
pragma strict
var bullete : GameObject;
var CD: float;
var Timer :float;
var FireSpeed :float;
var Speed : float;
function Start () {
}
function Update () {
if(Input.GetKey(KeyCode.Space)){
Fire();
}
if(Input.GetKey(KeyCode.W)){
this.transform.position.z = this.transform.position.z + (Speed*Time.deltaTime);
}
if(Input.GetKey(KeyCode.S)){
this.transform.position.z = this.transform.position.z + (-1* Speed*Time.deltaTime);
}
if(Input.GetKey(KeyCode.A)){
this.transform.position.x = this.transform.position.x + (-1* Speed*Time.deltaTime);
}
if(Input.GetKey(KeyCode.D)){
this.transform.position.x = this.transform.position.x + (Speed*Time.deltaTime);
}
}
function Fire(){
CD = 1- (FireSpeed/100);
if(Timer > CD){
Timer = 0;
Instantiate (bullete,this,transform.position,this.transform.rotation);
}else(
Timer = Timer + Time.deltaTime;
}
}
Comment
Answer by Kiwasi · Oct 30, 2014 at 03:22 AM
You have a ( on line 35 when you should have a {
For future questions please write the compiler error message as well.