- Home /
Question by
Shishkebabs · Jan 08, 2014 at 01:44 AM ·
javascripterror
Semicolon error using JS
Well I added semicolon already. Error at (18,46)
#pragma strict
var Bullet : Rigidbody;
var Spawn : Transform;
var BulletSpeed : float = 1000;
function Start () {
}
function Update () {
if(Input.GetButtonDown("Fire1")){
Fire();
}
}
function Fire(){
var bullet1 : Rigidbody = (Rigidbody)Instantiate(Bullet,Spawn.position,Spawn.rotation);
bullet1.AddForce(transform.forward *BulletSpeed);
}
Comment
Answer by robertbu · Jan 08, 2014 at 01:45 AM
It is your C# style casting that is causing the problem. Try this for line 18:
var bullet1 : Rigidbody = Instantiate(Bullet,Spawn.position,Spawn.rotation) as Rigidbody;
Thanks, the only problem now is that the bullet flies sideways :/ (spawns sideways) gonna try and figure it out........
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Input.GetMouseButtonDown(0) not working 2 Answers
Error I don't know how to fix 1 Answer
UnityScript coding error: 1 Answer