Problem w/ bullet trail script in episode 9 of

Updated on September 13, 2014 in [A] Brackeys Courses
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on September 13, 2014

I’ve been following all of the tutorials in the 2d platformer series, and this is the first time I’ve been seriously stuck with a script. Does any one know whats wrong with the code below? I would’ve looked at the script in the 2D platformer assets pack, but some of the newer scripts were absent, even though I redownloaded it. 

These are my errors: 
Assets/Weapon.cs(52,9): error CS1525: Unexpected symbol `}’
Assets/Weapon.cs(54,1): error CS8025: Parsing error

And here’s the script:

using UnityEngine;
 using System.Collections;
 public class Weapon : MonoBehaviour {
 public float fireRate = 0;
 public float Damage = 10;
 public LayerMask whatToHit;
 float timeToFire = 0;
 Transform FirePoint;
 public Transform BulletTrailPrefab;
 // Use this for initialization
 void Awake() {
 FirePoint = transform.FindChild ("FirePoint");
 if (FirePoint == null) {
 Debug.LogError ("No firepoint!? Say what?");
 }
 }
 // Update is called once per frame
 void Update () {
 if (fireRate == 0) {
 if (Input.GetButtonDown ("Fire1")) {
 Shoot();
 }
 } else {
 if (Input.GetButton ("Fire1") && Time.time > timeToFire){
 timeToFire = Time.time + 1/fireRate;
 Shoot();
 }
 }
 }
 void Shoot (){
 Vector2 mousePosition = new Vector2 (Camera.main.ScreenToWorldPoint (Input.mousePosition).x, Camera.main.ScreenToWorldPoint (Input.mousePosition).y);
 Vector2 firePointPosition = new Vector2 (FirePoint.position.x, FirePoint.position.y);
 RaycastHit2D hit = Physics2D.Raycast (firePointPosition, mousePosition-firePointPosition, 100, whatToHit);
 Effect();
 Debug.DrawLine (firePointPosition, (mousePosition-firePointPosition)*100);
 if (hit.collider != null) {
 Debug.DrawLine (firePointPosition, hit.point, Color.black);
 Debug.Log ("We hit " + hit.collider.name + " and did " + Damage + " Damage");
 }
 }
 void Effect (){
 Instantiate (BulletTrailPrefab, FirePoint.position, FirePoint.rotation)
 }
 }

  • Liked by
Reply
0 on September 13, 2014

Take out 1 of the “}” lines before Void Shoot()    It’s difficult to see without proper indentation.

FYI  in the error messages, the number it shows in the ( ) indicates which line number you should be looking at, and how far in on that line.

  • Liked by
Reply
Cancel