Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 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 /
This question was closed Sep 23, 2013 at 12:36 PM by Fattie for the following reason:

Duplicate Question

avatar image
0
Question by smasgames · May 30, 2011 at 08:56 PM · playerballwallcollidehealth

how to make a player die on collision

I am making a game were the ball is the player and i need to know how to destroy the player when it collides with the wall game object. is there a way to do it.

Comment
Add comment · Show 1
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 Fattie · Sep 23, 2013 at 12:37 PM 0
Share

mods delete duplicates pls

2 Replies

  • Sort: 
avatar image
1

Answer by Antony-Blackett · May 30, 2011 at 09:04 PM

Look at the OnCollisionEnter() docs. http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnCollisionEnter.html

after reading the docs add this script to your wall objects.

 function OnCollisionEnter(Collision collision)
 {
     if( collision.gameObject.tag == "Player" )
     {
         Destroy(collision.gameObject);
     }
 }
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 smasgames · May 30, 2011 at 09:32 PM 0
Share

so the player is the player and gameobject is the wall?

avatar image smasgames · May 30, 2011 at 09:34 PM 0
Share

(1,37): BCE0043: Unexpected token: collision.

avatar image iggy · May 31, 2011 at 01:57 PM 1
Share

C#

  • function OnCollisionEnter(Collision collision)

Javascript

  • function OnCollisionEnter(collision:Collision)

avatar image Sunlight4 · Oct 17, 2013 at 04:34 PM 0
Share

That does not seem to work.

avatar image
0

Answer by smasgames · May 31, 2011 at 10:58 PM

(@iggy and Antony Blackett) shall i put this script in the player or the wall:

function OnCollisionEnter(collision:Collision) { if( collision.gameObject.tag == "Player" ) { Destroy(collision.gameObject); } }

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 Cherno · Oct 17, 2013 at 04:44 PM 0
Share

On the wall, because you check if the other gameobject is taggedas Player. However, it would probably be easier to attach it to the player and check for the wall's tag.

avatar image Ahad1133N · Mar 20, 2021 at 05:21 AM 0
Share

Can you please send any video please it's an humble request!

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Player Health 3 Answers

How to make player (sphere) shoot the ball (another sphere)? 2 Answers

Need Help About Health,Damage 1 Answer

collision with wall so player dies 1 Answer

I need help with the player's health points 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