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 alimumtaz96 · May 11, 2020 at 01:13 AM · 3d#pragma

How i destroy the object of that part that collides with another object?

I am trying to do that my player(cube) is moving when it collides with the another cube e.g my player collides at the corner of another cube I want to destroy the the player part with another cube part collides

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 icehex · May 11, 2020 at 03:07 AM 0
Share

Hi, write some code using OnCollisionEnter() and if you have trouble post it as a question. https://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by lucasdvazquez7 · May 11, 2020 at 04:01 AM

I don't quite understand what you wanted to do.

What I understood was that you wanted to destroy the gameobject that your player collided with. To do that, you need to reference that gameobject in your player's script. For example:

 //You have to drag your enemy prefab here
 public GameObject enemy;
 
 //First: you have to add a Box Collider to your cube
 //Second: you have to create a tag to your enemy so that the player identifies it when it collides with it
 //Third: destroy the object you collided with
 void OnTriggerEnter(Collider other){
      if(other.tag == "enemy"){
            Destroy(enemy);
        }
 }

Hope this helps

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 alimumtaz96 · May 11, 2020 at 11:00 AM 0
Share

I am saying that my player that is cube left side collides with another cube I want to destroy the Left side of my player

avatar image
0

Answer by UnityToMakeMoney · May 11, 2020 at 04:36 AM

First off, the object needs to be a collection of other objects. If they are not a collection, then make a script so that they are always together.

Second, all you have to do now is tag each object in that collection so that when you collide with it, it gets destroyed. A good example of a collection of objects in a game would be like Snake, where each limb is attached to the head.

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 alimumtaz96 · May 11, 2020 at 11:00 AM 0
Share

I am saying that my player that is cube left side collides with another cube I want to destroy the Left side of my player

avatar image UnityToMakeMoney alimumtaz96 · May 11, 2020 at 06:44 PM 0
Share

Yes, that is what I am saying. make a player so that it looks like 1 object, but it is 2+ objects being held together. That way, when a specific part of a player is touched, you can destroy, hide, or whatever you want to do when you collide with it.

avatar image alimumtaz96 UnityToMakeMoney · May 11, 2020 at 07:19 PM 0
Share

But I didn't know that left side collides or right side mid it depends how the user play

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

127 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 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 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 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 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 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

Rotating a 3D object on the Y axis relative to the cursor's position? 2 Answers

2d scene into 3D scene, 0 Answers

Raycast Will Only Hit Target If Jumping Over Object Firing Raycast 1 Answer

How to rotate child object regardless of orientation? 0 Answers

Ground Check In Unity3D 2019.4? 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