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 Carl 2 · Apr 28, 2011 at 01:40 PM · physicsscorecollisionspoints

How can i destroy a collider on collision?

I was wondering if anyone could help me out with this little problem. Basically I want the player to be able to roll into an object (the player is a sphere shaped object) and get points for hitting the object, but I don't want the player to keep getting points if they roll into it after the first time.

Is there a script I can make to say destroy the collider on the object or is there a much better way of doing this?

Also I'm very new to scripting and I was wondering if anyone could also help tell me how to make a point system in the game and have the score appear on the screen.

Thanks guys!

Comment
Add comment · Show 3
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 · Apr 28, 2011 at 01:46 PM 0
Share

You've asked two separate questions, both of which have been asked countless times before. Please take a moment to search the existing questions (individually) before posting a new question - cheers!

avatar image Carl 2 · Apr 28, 2011 at 02:16 PM 0
Share

$$anonymous$$y apologies if it has been asked before, but I've spent ages searching for it and I never found anyone else asking this particular question.

No one seems to be asking how to keep an object physics based so it bounces away and you also get points for it.

avatar image crydrk · Feb 20, 2013 at 02:16 AM 0
Share

And I was searching for exactly this so I applaud him for posting here.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by flaviusxvii · Apr 28, 2011 at 02:31 PM

The problem here is that you've loaded your question with physics/collision/destroy stuff when you REALLY just wanted a way to only count collisions once.

You can do with with a simple boolean variable. Set it to true if it's false and count it. Ignore it otherwise.

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
avatar image
0

Answer by Joshua · Apr 28, 2011 at 01:44 PM

Give all the objects you want to be destroyable the same tag, for instance "Destroy". Add the follow script (or into an existing script) on the player.

function OnCollisionEnter (hit : Collision) {

 if(hit.gameObject.tag == "Destroy") {

     Destroy(hit.gameObject);

 }

}

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 Carl 2 · Apr 28, 2011 at 02:18 PM 0
Share

Thanks for the reply. The only problem with this is I don't want the objects to disappear into thin air, I want the objects to bounce away physics based, but I don't want the player to be able to score points from it if it has already been hit :)

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

1 Person is following this question.

avatar image

Related Questions

Apply rigid body force in opposite direction of collider 1 Answer

Find all objects currently colliding with trigger 1 Answer

Why cant I subtract point from my score? 1 Answer

Collision and score 1 Answer

[need help please] Score when AI Dies 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