x


Differences of OnCollisionEnter, OnTriggerEnter vs OnControllerColliderHit?

I am trying to write a box object that when the player dash into it it will break.

OnTriggerEnter/Stay - don't server the purpose, the box need to be non trigger;

OnCollisionEnter/Stay - doesn't work, and I don't understand why...Is it because CharacterController does not count as a collider so it won't work?

OnCharacterControllerHit - doesn't work either! ... I am coding on the box not on the player that has the charactercontroller. I guess that's why??(havn't try it yet)

Then here's my question : how can I script on the box side, but get the collision detection? ( i do'nt want to attach additional colliders @_@!)

Thanks!!!!

============================================================================== have a performance question, reference says "The Collision class contains information about contact points, impact velocity etc. If you don't use collisionInfo in the function, leave out the collisionInfo parameter as this avoids unneccessary calculations"

what collision info does it refer to? the Collision.contacts? does it simply mean if I don't access that parameter, the calculation will be saved? Makes me really curious. Thanks guys!! : )

more ▼

asked Mar 14, 2011 at 06:39 AM

Rei gravatar image

Rei
25 19 14 20

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

1 answer: sort voted first

The easiest way is to send a collision message to a GameObject upon OnCharacterControllerHit using SendMessage (although with a little bit of imagination there are more efficient ways).

more ▼

answered Mar 14, 2011 at 08:06 AM

Lab013 gravatar image

Lab013
415 3 3 14

Do you mean adding a line in the player(which has the character controller), to send a message to every collider that it's hitting with?

I didn't get it before but now I think that's what you mean. It's not the most efficient way but there's not that much overhead either. Thanks!

Apr 14, 2011 at 09:30 AM Rei
(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:

x4019
x2788
x1123

asked: Mar 14, 2011 at 06:39 AM

Seen: 2780 times

Last Updated: Mar 14, 2011 at 06:46 AM