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 /
avatar image
0
Question by DemetriX · Feb 26, 2014 at 06:06 PM · errorparsing

C# Parsing Error

Hi, I am getting the message Parsing Error but I don't know what is wrong since it is the only error statement in the console. Please help; below is my script code:

 using UnityEngine;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour 
 {
     public float speed;
     public GUIText countText;
     public GUIText winText;
     private int count;
 
     void Start ()
     {
         count = 0;
         SetCountText ();
         winText.text = "";
     }
 
      void FixedUpdate ()
     {
         float moveHorizontal = Input.GetAxis ("Horizontal");
         float moveVertical = Input.GetAxis ("Vertical");
 
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
 
         rigidbody.AddForce (movement * speed * Time.deltaTime);
     }
 
         
     void OnTriggerEnter(Collider other) 
     {
         if (other.gameObject.tag == "PickUp") 
         {
             other.gameObject.SetActive(false);
             count = count + 1;
             SetCountText ();
         }
 
     }
 
     void SetCountText ()
     {
         countText.text = "Count: " + count.ToString();
         if (count >= 12) 
         {
             winText.text = "YOU WIN!";
         }
 
     }
 
 
     void OnTriggerEnter (Collider other){
         if (other.gameObject.tag == "NextLevel")
         {
             other.gameObject.CompareTag("Player");
             Application.LoadLevel("Scene2");
         }
             
      
 }
Comment
Add comment · Show 5
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 perchik · Feb 26, 2014 at 06:06 PM 0
Share

Please post the text of the error

avatar image DemetriX · Feb 26, 2014 at 06:08 PM 0
Share

Never$$anonymous$$d, I found out the problem; I was missing a } for the one in line 51. But now I have another problem. It says: Assets/Scripts/PlayerController.cs(51,14): error CS0111: A member `PlayerController.OnTriggerEnter(UnityEngine.Collider)' is already defined. Rename this member or use different parameter types

avatar image DemetriX · Feb 27, 2014 at 05:22 PM 0
Share

How am I not specific enough? And who says I didn't look up for the solution myself? You think I would ask here if I didn't look for an answer by myself in the Script Reference?

avatar image perchik · Feb 27, 2014 at 05:25 PM 0
Share

That's fine, but you need to post that in your question. Post the code you've tried, what you've done to try to solve the problem.

Frankly, there are users who just post here without looking anything up or trying anything and those questions are ignored by moderators.

avatar image DemetriX · Feb 27, 2014 at 05:31 PM 0
Share

I know there are users like those whom you described, but I am not one of them ;) I tried to somehow write an "if" statement after the
countText.text = "Count: " + count.ToString(); if (count >= 12) { winText.text = "YOU WIN!"; }

part of the script, but it didn't work out. And then I tried to look up for the SetActive function in the Reference, but it didn't help me...

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer Wiki

Answer by perchik · Feb 26, 2014 at 06:10 PM

Your error message says it. There's two definitions of "OnTriggerEnter" at lines 29 and 51.

Comment
Add comment · Show 10 · Share
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 DemetriX · Feb 26, 2014 at 06:29 PM 0
Share

Can I write it somehow else to achieve the same thing, but not to double write OnTriggerEnter?

avatar image Jamora DemetriX · Feb 26, 2014 at 06:29 PM 0
Share

Please use the very small "add new comment" button for comments. Answers are meant to be solutions to the asked question.

avatar image perchik · Feb 26, 2014 at 06:30 PM 0
Share

I'm not entirely sure what you're trying to achieve, but I don't see why you can't just combine the functions:

 void OnTriggerEnter(Collider other) 
     {
        if (other.gameObject.tag == "PickUp") 
        {
          other.gameObject.SetActive(false);
          count = count + 1;
          SetCountText ();
        }
        if (other.gameObject.tag == "NextLevel")
        {
          other.gameObject.CompareTag("Player");
          Application.LoadLevel("Scene2");
        }
  }
avatar image DemetriX · Feb 26, 2014 at 09:29 PM 0
Share

Thank you very much perchik, you have solved my problem :) I would upvote you, but I don't have enough $$anonymous$$arma points :P

avatar image DemetriX · Feb 27, 2014 at 05:18 PM 0
Share

Since you guys keep deleting my questions, I'll ask here. How can I make a certain object (lets say it's name is Wall) deactivate if a text displays on the screen?

avatar image perchik · Feb 27, 2014 at 05:20 PM 0
Share

Your question is being deleted because it's not a specific, and you haven't posted anything about what you've tried or looked up. UA isn't for questions that are this vague.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unexpected error 1 Answer

How do I fix this really wierd parsing error? 0 Answers

I am having a parsing error in a C# pause script, can anyone help? 1 Answer

Json parsing error Unity 5.6 0 Answers

Jukebox parsing error 2 Answers


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