- Home /
Need help fixing syntax errors
var Char_Bullet : Transform;
function Update () { if(Input.GetButtonDown("Fire1")) { var bullet - Instantiate(Char_Bullet,GameObject.Find("Gun_Spawn").transform.position,Quaternion.identity); bullet.rigidbody_Addforce(transform.forward * 2000);
}
}
hey, im new to unity but i got the code from a video, trying to show me how to make my gun shoot.
i always get the error Assets/Standard Assets/Scripts/Shoot_Rigid_Bodys.js(6,35): UCE0001: ';' expected. Insert a semicolon at the end.
Help?
Answer by Mike 3 · Jul 09, 2010 at 12:51 AM
there are a few errors there
you're using - instead of = after bullet, you don't have a ) after Quaternion.identity, and you're using _ instead of . for rigidbody.AddForce
Corrected:
var Char_Bullet : Transform;
function Update () { if(Input.GetButtonDown("Fire1")) { var bullet = Instantiate(Char_Bullet,GameObject.Find("Gun_Spawn").transform.position,Quaternion.identity); bullet.rigidbody.AddForce(transform.forward * 2000); } }
when i fire it just falls out, and i get error $$anonymous$$issing$$anonymous$$ethodException: $$anonymous$$ethod not found: 'UnityEngine.Rigidbody.Addforce'.
@$$anonymous$$ike, when you're editing/fixing posts, you might also want to edit the title to make more sense, as well as the tags. error and help (and unity) are all useless. :)
$$anonymous$$ike - change Addforce to AddForce (capital F)
@$$anonymous$$ike - negative reinforcement, that's good. But remember, you need to punish them immediately after they screw up your code, or they won't understand why you're slapping them... :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613064204im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
UCE0001: ';' expected. Insert a semicolon at the end. 2 Answers
Problem with my Hack and Slash tutorial Health bar script 1 Answer
doing force and spin on a gameobject when clicking on plane. 2 Answers
UCE0001: ';' expected. Insert a semicolon at the end." 1 Answer
help with UCE0001: ';' expected. Insert a semicolon at the end 3 Answers