- Home /
Other
C# Code errors
I am a little new to unity and very new to C# and I am making a 2d platformer game and this is my script to shoot. Im getting these errors 1. (30,20) Unexpected symbol 'else' 2. (31,41) Unexpected symbol '(' 3. (31,64) Unexpected Symbol '>' 4. (31,75) Unexpected Symbol ')' 5. (32, 36) Unexpected Symbol '=' 6. (36,9) Parsing error It would be much appreciated if anyone could help me
using UnityEngine; using System.Collections;
public class weapontry : MonoBehaviour {
public float fireName = 0; public float Damage = 10; public LayerMask whatToHit;
float timeToFire = 0; Transform firepont; // Use this for initialization void Awake () { firepoint = transport.FindChild ("FirePoint"); if (firepoint == null) { Debug.LogError ("No Fire Point = whatt bish");
// Update is called once per frame
void Update () {
if (fireRate == 0) {
if (input.GetButtonDown ("Fire1")( {
}
else
if Input.GetButtonDown ("Fire1") && Time.time > timetoFire) {
timetoFire = Time.time +1/fireRate;
} void Shoot () { Vector2 mousepostition = new Vector2 (Camera.main.ScreenToWorldPoint (Input.mousePosition.x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y Vector2 firePointPosition (firePoint.position.x, firePoint.y); RaycastHit2d hit =Physics2d.Raycast (firePointPosition, mousePosition-firePointPosition, 100,notToHit) if (hit.collider !=null){ Debug.Log ("Test") Debug.Drawline (firePointPosition, hit.point, Color.red); Debug.log ("We hit " + hit.collider.name + "and did" + Damage + " damage.")}
Format your code so that we can actually see what's going on. After that, try looking at the errors given. They tell you not only what the issue/problem is, but also on what line the error is occurring.
Seriously, it won't help much. I think there's an error on pretty much every line. At first glance, I see:
Transform firepont;
- should be firepoint.
firepoint = transport.FindChild ("FirePoint");
- transport not declared.
{ Debug.LogError ("No Fire Point = whatt bish");
- unclosed }.
if (input
- should be Input.
if (input.GetButtonDown ("Fire1")( {
- ( should be ).
'if (input.GetButtonDown ("Fire1")( { }' - what is meant to happen if Fire1 is down?
Time.time > timetoFire
- should be timeToFire.
Time.time +1/fireRate;
- should be 1f/fireRate.
mousepostition
- should be mousePosition.
Vector2 mousepostition = new Vector2 (Camera.main.ScreenToWorldPoint (Input.mousePosition.x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y Vector2 firePointPosition (firePoint.position.x, firePoint.y);
- literally have no idea.
RaycastHit2d hit
- should be RaycastHit2D.
Physics2d.Raycast
- should be Physics2D.Raycast
Debug.Log ("Test") Debug.Drawline
- missing a semicolon.
Debug.log ("We hit " + hit.collider.name + "and did" + Damage + " damage.")
- missing a semicolon.
That's why I quite seriously suggest the OP to start again. Add one line at a time. And follow some basic coding tutorials.
Follow this Question
Related Questions
Unfixable Assets/Scripts/PlayerAttack.cs(30,15): error CS1525: Unexpected symbol `private' 1 Answer
Object reference not set to an instance of an object in functions 1 Answer
Getting index of the smallest number in a list 1 Answer
Burgzergarcade Why am i getting an error after re-importing? 1 Answer