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 Michael 8 · Mar 02, 2012 at 07:04 PM · c#collisiontrigger

Detecting collision between two objects without triggers.

I want my projectile to knocked down the objects it hits (rigid body vs rigid body) and disappear right after doing that. The only way I can detect a collision via script is by assigning a trigger. The problem is that once I assign a trigger to the projectile it just disappears when touching the object it supposed to knock down without affecting it.

Comment
Add comment · Show 2
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 Exalia · Sep 03, 2013 at 11:37 AM 0
Share

Sorry for necro but there was no answer and I'm wanting the same thing :|

avatar image poncho · Sep 03, 2013 at 12:06 PM 0
Share

These 4 answers are basically the same, and they are all valid... Again, check for unity's documentation about OnCollisionEnter on the first answer...

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Moohasha · Mar 02, 2012 at 07:24 PM

Why do you have to use a trigger? Both objects should have colliders that AREN'T triggers, then just use the OnCollisionEnter function on your bullet.

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 Exalia · Sep 03, 2013 at 12:26 PM

I managed to get this working immediately after posting so I'll paste it here

 using UnityEngine;
 using System.Collections;
 
 public class ColliderScript : MonoBehaviour 
 {
     void OnCollisionEnter(Collision other)
     {
         if (other.gameObject.tag == "Enemy")
         {
             Destroy(other.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 poncho · Sep 03, 2013 at 10:05 PM 0
Share

Yes, it is the same as the last 4 answers with better, format, I guess you are looking to get some rep, so here, take 10 points

avatar image Exalia · Sep 03, 2013 at 10:23 PM 0
Share

I'm here to learn oddly enough...

Earlier I created a script that used on TriggerEnter as quite a few tutorials use that to create similar effects like pick up but I needed both objects to be rigid.

I googled it, found this page did a copy and paste and it didn't work, I changed it slightly (tags not names) and it worked.

I didn't come here looking for "points" this isn't a dick waving contest its people trying to help eachother

avatar image poncho · Sep 03, 2013 at 10:39 PM 0
Share

why would some one who wants to learn be copy pasting code?, if an answer said OnCollisionEnter, and it has the link to unity's documentation, that's more than enough to learn how to use it, also, use names for especific objects, and tags for groups of objects, you just have to make sure which you will be using and check the object has the one you need, good luck, and sorry if I offended you somehow

avatar image Exalia · Sep 03, 2013 at 11:12 PM 0
Share

That's like saying why do people who make better cars use wheels. I'm not here to invent the next best thing, a very basic function wasn't working. Not because I didn't know what I wanted to do or how to do it but because I didn't know which word to type.

There seems to be this odd vibe from some people on here where they want you to give them a reason to help you

"Why do you need this?" "You don't need to do that do this it's better"

It's unity answers not unity opinions

I don't need to learn how OnCollision works it's self explanatory and is present in every game engine I've used. what I did need to learn is that it exists and how to spell it. That's it.

Thanks for initially assu$$anonymous$$g the worst and continuing to insult my intelligence.

avatar image
0

Answer by poncho · Mar 02, 2012 at 08:32 PM

you should use the collision methods

 void OnCollisionEnter(Collision myCollisionInfo)
 {
 
 }

you just need to make sure you have Collider attached to the gameobjects you are going to collide

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 Michael 8 · Mar 02, 2012 at 08:46 PM

Thanks for the help!

I'm using:

  void OnCollisonEnter(Collision collision)
 {
     Destroy(gameObject);
 }

And nothing happens, so obviously I'm doing something derpy... :-/

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

9 People are following this question.

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

Related Questions

On Trigger Enter, Collide with object, specific collision 1 Answer

Animation with frozen player ?? 0 Answers

Why the npc character walking strange when using a Rigidbody and Is Kinematic on enabled ? 1 Answer

How to enter trigger a certain amount of times before executing code? 1 Answer

Open door = load scene c# issues 4 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