Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
This question was closed Oct 12, 2015 at 05:42 AM by Crixus for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Crixus · Oct 11, 2015 at 01:24 PM · collisionerrorgameobjectscore system

[SOLVED] Stop counting score code error!

Hello! I am working at my video game, a simple 2D game, a kind of side scroller. Bellow you have some pics with game. The problem is with a code. I try to make a code that will stop the counting of score when the character hits an obstacle. I have used a collide function but from 3 days it gives me two errors. Bellow I give you the code and some pics with errors. I really need help and i will appreciate your help. Thanks!

The game

alt text

The code with funtion. Funtion is last.

 using UnityEngine;
 using System.Collections;
 
 public class CharacterMovment : MonoBehaviour {
     public float speed = 3.5f;
     public UIManager ui;
     
     
 
     // Use this for initialization
     void Start () {
 
         //ui = GetComponent<UIManager> ();    
 
     }
     
     // Update is called once per frame
     void Update () {
         /*if (Input.GetKey (KeyCode.D))
             transform.position += new Vector3 (speed * Time.deltaTime, 0.0f, 0.0f);
         if (Input.GetKey (KeyCode.A))
             transform.position -= new Vector3 (speed * Time.deltaTime, 0.0f, 0.0f);*/
         if (Input.GetKey (KeyCode.W))
             transform.position += new Vector3 (0.0f, speed * Time.deltaTime, 0.0f);
         if (Input.GetKey (KeyCode.S))
             transform.position -= new Vector3 (0.0f, speed * Time.deltaTime, 0.0f);
 
 
     }

     void OnCollisionEnter(Collision col)
     {
 
         if (col.GameObject.tag == "Obstacle")
         { ui.GameOverActivated; }
 
     }
     
 }
 

The erros

alt text

And this is UIManager. I dont konw, but maybe it will help you.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 
 public class UIManager : MonoBehaviour {
 
     public Text ScoreText;
     int score;
     bool GameOver;
 
     // Use this for initialization
     void Start () {
 
         score = 0;
         InvokeRepeating("ScoreUpdate", 0.3f, 0.01f);
         GameOver = false;
     
     }
     
     // Update is called once per frame
     void Update () {
 
         ScoreText.text = "SCORE  " + score;
     
     }
 
     void ScoreUpdate ()
     {
         if (GameOver == false)
         { score += 1; } 
     }
 
     public void GameOverActivated ()
     {
         GameOver = true;
     }
 
     public void Play ()
     {
 
         Application.LoadLevel("PrincipalLevel");
 
     }
 
     public void Pause ()
     {
 


That is it! I have search on google the problems, but i did not find something clear that cand help me. If is someone who can help me, I will appreciate. Thanks again!

3.png (91.3 kB)
2.png (177.1 kB)
Comment
Add comment
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

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Linus · Oct 11, 2015 at 01:25 PM

Use gameObject not GameObject :)

Gave you some points as clearly you do not need to be in moderation que. Prime example of how to ask for help.

Comment
Add comment · Show 4 · 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 Crixus · Oct 11, 2015 at 03:59 PM 0
Share

Oh God what stupidness :)))) Thank you very much. But the second error still appear. I think that it is also a little thing :) And thanks for the rep points also. I have seen something about moderation or something like "the question need to be reviwed by a moderator" but I didn't gave no importance. I dont know how happend.

avatar image Crixus · Oct 11, 2015 at 04:15 PM 0
Share

SOLVED! Thanks again for help! The second, was also a stupidness :))

avatar image Crixus · Oct 11, 2015 at 04:20 PM 0
Share

So. First error was solved by @Linus and the scond error i have solved it. I just changed some things.

Ins$$anonymous$$d of

 ui.GameOverActivated;

I have putted

 UI$$anonymous$$anager.GameOver = true;

And it is working.

avatar image Linus · Oct 11, 2015 at 10:30 PM 0
Share

Glad it got solved. Did not look more into it when I saw the first error. Often they stack up when there is one error.

I once spent days before I saw that i had used OnEnabled ins$$anonymous$$d of OnEnable.

Yes new users have their question sent to moderation que. They also cant post comments, so they end up posting answers ins$$anonymous$$d of comments.

Please mark the question as answered.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Count objects inside a dynamic area? 0 Answers

Soccer game, more realistic net 1 Answer

How to make a Compact-Disc shaped collider object with an empty hole inside? (2D, not a 3D torus) 0 Answers

How do add scenes on the Countdown Timer 0 Answers

One script with multiple Gameobject only one Works 0 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