x


Collision with no onCollisionEnter

Hello, I'm making a fairly simple tank game. I'm having two problems that I can not for the life of me figure out. The first is that (with no enemy ai) my shells collide with the enemy tank, however there is no onCollisionEnter called. Secondly when the ai is activated there is not a collision at all. I feel this may be related (though they may not be) and any help would be greatly appreciated. Thanks!

more ▼

asked Dec 08 '10 at 01:31 AM

Auz gravatar image

Auz
1 1 1 1

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I got so fed up with not understanding collisions in my test I just made a supersmall project, built a ton of small blocks all with a permutation of Rigidbody Yes/No Character Controller Yes/No ColliderBox Yes/No (IsTrigger on Collider Yes/No)

And then I built a player block and kept slamming it into everything with ALL those functions active and a lot of Debug.Log("Player collided with this is that").

Before you know it you understand collisions in Unity. Sometimes a wall of text and some pictures is good enough, but here I would say, go use it before you lose it. I know I would have.

Some things I noticed:

Constant Force + character controller = Only torque will have any effect the rest becomes pointless to use.

Rigidbody + Rigidbody = Physical collisions only, like bowling

Character Controller + Collider = Use the special OnCollision functions or the OnControllerColliderHit(ControllerColliderhit cch){} function

Character Controller + Collider + IsTrigger = You can walk through the object but can catch the collision in OnTrigger(Exit/Enter/Stay)

Before I wall this to much , go try it out , really , it'll help.

Problems I had with collisions that may help out , all discussed and answered , except the one I answered myself:

Elevator

CapsuleCasting

General Approaches on Collision detection in Unity

and this one may be usefull Rigidbody link here

more ▼

answered Dec 08 '10 at 02:09 PM

Proclyon gravatar image

Proclyon
1.4k 10 13 32

(comments are locked)
10|3000 characters needed characters left

So that definitely helped a bit. I've started seeing trigger's go off when the shells pass through walls but not through the tanks. I've started to gather that there isn't a trigger that goes off when traveling through a Character Collider. If that is the case, is there anyway to go about making some variation of that collision happen without having to change the way my tanks move? This is all fairly new to me so I'm trying to quickly grasp what is going on throughout the project. If I can provide anything that will be helpful please let me know and thats for the above post. It helped make some progress happen.

more ▼

answered Dec 08 '10 at 08:51 PM

Auz gravatar image

Auz
1 1 1 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x227
x124

asked: Dec 08 '10 at 01:31 AM

Seen: 1287 times

Last Updated: Dec 08 '10 at 01:31 AM