- Home /
OnTriggerEnter Or OnCollisionEnter?
Hello Unity3D.I have a question about collisions.Which Collision Method is best for a Fighting Game OnTriggerEnter or OnCollisionEnter?The reason i ask this question is that fact that i hear some people say OnTriggerEnter is better and some please also say OnCollisionEnter is Better?If one is indeed better than the other or if they both are needed?Can anyone explain to me why?
Answer by Bentoon · Jan 13, 2015 at 07:01 PM
Great question Was just reading up on it myself: http://docs.unity3d.com/Manual/CollidersOverview.html
$$anonymous$$y guess would be the pros and cons of OnTriggerEnter And OnCollisionEnter
Answer by tanoshimi · Jan 13, 2015 at 07:10 PM
One is not "better" than the other; they do different things. OnCollisionEnter is called when two colliders hit. OnTriggerEnter is called when a collider enters a trigger (i.e. a collider with "IsTrigger" set).
True "collisions", used in conjunction with non-kinematic rigidbodies, are for when you want to simulate the physical effects of two objects colliding - the conservation of momentum, forces applied based on the angle of incidence etc. OnCollisionEnter is called when these objects first hit each other and gives you properties of the point of collision, but the physics engine itself automatically resolves changes in motion of the two bodies etc.
OnTriggerEnter is used (with kinematic or non-kinematic rigidbodies) to detect when one object has entered another's trigger. Note that, in this case, the physics engine does not prevent the object from doing so - unlike a collider, you do not "bounce off" a trigger. It can be thought of as an invisible "zone", and you can decide what happens to the object having entered that zone.
Either can be used for a fighting game - it really depends how you are planning to control the kinematics of the characters.
OH....So both of them can be used but it just depends on how i used them in my game that i am creating?
Answer by merlin4 · Feb 22, 2021 at 02:00 PM
Neither. You want to use Raycast/Linecast/Boxcast etc to actually tell if in attack hits generally.
Your answer
Follow this Question
Related Questions
AddTorque Isn't Working? 1 Answer
Dragging object out of position 2 Answers
Parent rigidbody using its childrens colliders. Should it work or am I stupid? 2 Answers
Collsion without ririgibody 1 Answer