Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 mangohack · Jun 20, 2011 at 10:56 PM · scoreboard

scoreboard problems

im trying to create a scoreboard but i got a lot of error here is my code

 function Update () {
 
 function OnControllerColliderHit(hit  : ControllerColliderHit);
 
 var score : GameObject; 
 if(myCollision.gameObject.name == "fruit")
 
      score.GetComponent("Score").AddToScore(); 
      Destroy (gameObject); 
   }

i want when my player hit the gameodject fruit get one point but i got error

Comment
Add comment · Show 7
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 Chris D · Jun 20, 2011 at 11:06 PM 0
Share

There are a number of things wrong with this script. I would recommend taking the time to go through a few scripting tutorials before plunging right into things. It will help in the long run.

For a good list of tutorials (though the list is a little dated now), check out this answer.

avatar image Goody! · Jun 20, 2011 at 11:10 PM 0
Share

1st you probably dont want it in the update, that means it's getting fired off many times per second.

Check this out... http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html

...and see if it helps.

avatar image mangohack · Jun 20, 2011 at 11:14 PM 0
Share

can u fixe my code ChirsD to see what i did wrong please i will help me

avatar image Chris D · Jun 20, 2011 at 11:22 PM 1
Share

No, I'm not going to write your code for you. I've kindly recommended a set of tutorials - try google for more. It's clear that you're new to scripting, and that's good, but you need to learn some basics before any code we write will actually benefit you. I wish you luck.

avatar image mangohack · Jun 20, 2011 at 11:33 PM 0
Share

Ok, thank you for your suggestions and for taking an interest in my learning. I will continue to wait for an answer, but I have taken your comments under advisement.

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Dreamblur · Jun 20, 2011 at 11:04 PM

Remove the semi-colon at the end of the line containing OnControllerColliderHit.

Where is myCollision getting initialized?

EDIT: And what is Update doing on top of the code?

EDIT2: I'm lost. Is that 2 functions mashed up together? XD

Comment
Add comment · Show 1 · 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 mangohack · Jun 20, 2011 at 11:16 PM 0
Share

i don't really know i just edit a example of a scoreboard that i found in google lol if u fixe it it will help me

avatar image
0

Answer by Chris D · Jun 20, 2011 at 11:58 PM

You need to use OnCollisionEnter() in conjunction with GameObject.Tag and, presumably, some GUI shenanigans. I'm not going to write your code for you (and I don't necessarily speak for everyone here) but I will help you if you have specific questions about things and are willing to put some effort in.

You won't understand what your code does until you try to learn it.

Comment
Add comment · Show 2 · 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 mangohack · Jun 21, 2011 at 12:05 AM 0
Share

ok know i got ti

avatar image Chris D · Jun 21, 2011 at 12:10 AM 0
Share

Good to hear! The convention on this site is to accept the answer that you use (the check box next to the vote up/down buttons) so that others with similar issues can see that there's a valid solution. Good luck with your project.

avatar image
0

Answer by mangohack · Jun 21, 2011 at 11:38 AM

thankyou very muchhhhhhhhhhhh lol i fixed it look at my code

var score : GameObject;

function OnControllerColliderHit(hit : ControllerColliderHit) {

if(hit.gameObject.tag == "Floor")

  score.GetComponent("Score").AddToScore(); 
 

}

but know i want to know how to create a function Kill () that when my player hit the floor disappear.

Comment
Add comment · 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Making a scoreboard with a timer 2 Answers

No proper Update and function call between objects ? 1 Answer

I want to know how to save high score. 1 Answer

Save User Score On Cloud, And Showing LeaderBoard According To These Scores 3 Answers

GooglePlayGames Scoreboard doesn't display when called 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