• 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 Marshal_Alessi · Nov 29, 2015 at 08:58 PM · c#unity 5collisionscripting problemscriptingbasics

Collision Detection Not Working (Unity 5.2.3)

Hello!

I have been making a game, and I'm at the point of which I'm adding in Enemy AI who swing and attack the player. Unfortunately, I can't get the detection to work. Collision is pretty rudimentary, but for whatever reason, it's not clicking. I have been reading several articles online, trying to understand why it's not working, but nothing I have read has bore a viable solution.

For the record, both the enemy AI and player have Mesh Colliders, neither of them have the "Trigger" option or the convex option selected. Both have Rigidbodies. I put a debug.log bit in my code to see if it would detect anything, and it does not...If I'm missing something, please let me know.

 using UnityEngine;
 using System.Collections;
 
 public class EnemyManager : MonoBehaviour {
 
     void OnColliderEnter(Collision coll) {
         Debug.Log ("Object Detected");
         if (coll.gameObject.tag == "Player") {
             Debug.Log ("Hit Player");
         }
     }
 }
 
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

5 Replies

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

Answer by holymio · Nov 30, 2015 at 06:46 PM

I had the same problem. I downgraded to version 5.2.2 and everything was working fine. I assume this is a bug in the 5.2.3 version.

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 Marshal_Alessi · Dec 03, 2015 at 07:12 AM 0
Share

Tried it, and it works. That's frustrating, but I'm glad I know it wasn't me now.

avatar image
0

Answer by Mrslayer01 · Nov 29, 2015 at 10:23 PM

I'm not quite sure why that is not working but what you could always do is put a boxcollider around them and just make it a trigger and see if it works that way.

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 Marshal_Alessi · Nov 29, 2015 at 10:36 PM

I could do that for test purposes, but that wouldn't work in game, as I don't want it to be a constant damage, only when they are swinging. I'll try it for test sakes.

Also, I noticed I had typed in OnColliderEnter, I have changed it to the correct OnCollisionEnter.

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 liam1135 · Dec 03, 2015 at 01:06 PM

Same issue here. 5.2.3 broke all collision in our game.

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 saybor · Feb 21, 2016 at 07:31 PM

Same issue here. All collision broken on Android from 5.2.3 till 5.3.2 On PC and Editor working normal

Downgrade to 5.1 or 5.2 solving this issue.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

50 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

Related Questions

OnCollisonEnter2D Not Firing after checking collider 1 Answer

Cannot detect trigger 2 Answers

I need help working out a C# script with error CS0120 1 Answer

Adding a cost reduction to my purchasable items 1 Answer

Performance peaks in ScriptRunBehaviourUpdate 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges