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 @_@!)
============================================================================== 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!! : )
Answer by Lab013
Mar 14, 2011 at 08:06 AM
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).
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!
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
No one has followed this question yet.
Getting Character controller to fit model?
Character Controller Child Collisions
Detect RaycastHit on Character Controller
OnCollisionEnter Push Object Problem
How to deal the 2d platform physics?