Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Jan 03, 2015 at 11:14 AM by tanoshimi for the following reason:

Other

avatar image
0
Question by whevesy · Jan 03, 2015 at 11:10 AM · c#error

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.")}

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image justin35f · Jan 03, 2015 at 11:16 AM 0
Share

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.

avatar image tanoshimi · Jan 03, 2015 at 11:33 AM 0
Share

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.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

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

Hey guys, im starting do make a RPG game and in the Level system script(I called it "PlayerStatsController") i have an error: Parser Error : Unexpected symbol `public'. My script above: 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges