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 /
This question was closed Sep 10, 2015 at 07:37 AM by Orc_Horn_Productions for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Orc_Horn_Productions · Sep 09, 2015 at 09:55 PM · c#scripting problemcollisioncollision detectiononcollisionenter

[URGENT!!!] OnCollisionEnter is not working; need help to figure out if I've missed something or if it's a Unity 5 bug.

Hi all,

I'm having trouble getting OnCollisionEnter() to record a collision (code below). I've used OnCollisionEnter() before and for the life of me can't think what's gone wrong this time. I need help deciding if it's user error on my part or if this is a common issue with Unity5. Also I would prefer to avoid having to use OnTriggerEnter() on this occasion if possible.

Now we've got the production deadline fast approaching and with time running out I'm open to any and every suggestion. Whoever helps me resolve this issue, if they're interested, has earned a Steam Key after release.

Okay now for the details:

 using UnityEngine;
 using System.Collections;
 
 public class ColSparks : MonoBehaviour 
 {
     private void OnCollisonEnter (Collision other)
     {
         print ("Collision Detected");    
     }
 }

The GameObject detecting the collision

  • Script is attached to the GameObject.

  • gameObject has Rigidbody && SphereCollider components attached.

  • Rigidbody is NOT kinematic.

  • SphereCollider is NOT set as Trigger.

The other.gameObject

  • gameObject has BoxCollider component attached.

  • BoxCollider is NOT set as trigger.

Extra Info

  • Their respective physics layers are set to interact with one and other.

  • Similar set-up used successfully in another scene (note this was being tested in a Debug environment so no conflicts would occur).

  • Entire project is C#

  • The script has been stripped back for debugging in order to try and print() the collision to check it works.

Many thanks in advance! I look forward to hearing your ideas.

Ross

Comment
Add comment · Show 5
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 RLin · Sep 10, 2015 at 01:05 AM 0
Share

Remove the private before oncollisionenter

avatar image Noob4Sale · Sep 10, 2015 at 02:10 AM 3
Share

If the script above is the exact same as in your project,you misspelt OnCollisionEnter.

avatar image Orc_Horn_Productions Noob4Sale · Sep 10, 2015 at 07:35 AM 0
Share

@Noob4Sale

You know I can't believe it was that... It's working as intended now. Even after you pointed it out it still took me a $$anonymous$$ute to see the missing "i".

I'm putting it down to stupidity induced by writing too many coroutines in one day :-P

Even though it was such a simple mistake I believe I offered a S$$anonymous$$m $$anonymous$$ey to the guy that helped! If you want it when it becomes available drop an email to orc-horn-productions@outlook.com FAO Ross.

Cheers buddy!

avatar image Eric5h5 · Sep 10, 2015 at 05:14 AM 0
Share

Removing private will do nothing since that's the default anyway.

avatar image getyour411 · Sep 10, 2015 at 07:21 AM 1
Share

EDIT: Just read @Noob4Sale - that's surely it.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Orc_Horn_Productions · Sep 10, 2015 at 07:36 AM

Noob4Sale · 5 hours ago 2 Reply Share

If the script above is the exact same as in your project,you misspelt OnCollisionEnter.

Big thanks to the eagle eyed Noob4Sale :-)

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

Follow this Question

Answers Answers and Comments

32 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

Related Questions

Resize Array Based on Value 2 Answers

2D Platformer - Action When Key Is Pressed During Collision C# 0 Answers

if statement not working when detecting collision between two prefabs 1 Answer

Multiple Cars not working 1 Answer

I don't think I get collision box, can someone help? 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