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 /
  • Help Room /
avatar image
0
Question by TUTOCF · Feb 14, 2017 at 06:12 PM · collisiondestroydetectiongameobject.tag

OnCollisionEnter doesn't work !

Hello ! I searched on Google but I didn't find my problem's solution. I'm creating a game, I've got a sphere, and that sphere (controlled by a joystick because it's a mobile game) has to move on a road and doesn't touch the oaks which are around the road. I did a script called "Collision" : using System.Collections; using System.Collections.Generic; using UnityEngine;

 public class Collision : MonoBehaviour 
 {
     void OnCollisionEnter(Collision col)
     {
         if(col.gameObject.tag == "Oak")
         {
             Destroy(gameObject);
         }
     }
 }

This script is made in order to destroy the sphere when it touches the oak. The oak is tagged "Oak". My oaks and my sphere have got a "RigidBody" (not 2D, this is a 3D game). That "RigidBody" hasn't got "Is Kinematic" checked.

I tried to change Destroy(gameObject); by Debug.Log("Non!") but this text doesn't appear in my console. I hope that I gave you enough details to find out what's my problem and where's it ! Sorry if my English isn't good, I am out of English speakers' countries. :D

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by TUTOCF · Feb 14, 2017 at 08:40 PM

I succeeded !!! The Sphere Collider doesn't work ! You've to use BOX COLLIDER ! I don't know why, but now it works.

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
1

Answer by HenryStrattonFW · Feb 14, 2017 at 07:57 PM

Your error may likely be because Unity does not recognise the method since you have named your own class "Collision" which will conflict with the existing "Collision" type. So unity doesn't recognise your method as its special method to call since it does not match the parameter requirements.

Rename your script to something else (and avoid using existing names in future as it's never a safe thing to do unless using namespaces). And see if that works.

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 TUTOCF · Feb 14, 2017 at 07:58 PM 0
Share

Thank you. I am gonna try.

avatar image TUTOCF · Feb 14, 2017 at 08:05 PM 0
Share

That still doesn't work. I renamed it as "DestructeurObjects". Do you want to see something else in my settings ?

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

126 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

Related Questions

Unity 2D sorting item by color 0 Answers

Selective Collision Detection 2 Answers

My collision is not detecting 1 Answer

Best way to do Collision detection when you have multiple enemies/allies around you 0 Answers

2D: Destroy object with dynamic collider after exiting object with static collider 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