• 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 /
avatar image
7
Question by IKilledKenny_2 · Jan 13, 2015 at 06:55 PM · javascriptcollisionrigidbody

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?

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

3 Replies

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

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 alt text


screen shot 2015-01-13 at 2.01.27 pm.png (208.0 kB)
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 IKilledKenny_2 · Jan 13, 2015 at 08:40 PM 0
Share

$$anonymous$$y guess would be the pros and cons of OnTriggerEnter And OnCollisionEnter

avatar image
21

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.

Comment
Add comment · Show 3 · 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 IKilledKenny_2 · Jan 13, 2015 at 08:39 PM 0
Share

OH....So both of them can be used but it just depends on how i used them in my game that i am creating?

avatar image ismaelnascimento01 · May 21, 2017 at 01:16 AM 0
Share

Very good explication !

avatar image patrickabroad · Aug 06, 2017 at 02:54 PM 0
Share

Thanks, tanoshimi. That cleared it up for me.

avatar image
0

Answer by merlin4 · Feb 22 at 02:00 PM

Neither. You want to use Raycast/Linecast/Boxcast etc to actually tell if in attack hits generally.

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

30 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

Related Questions

Collsion without ririgibody 1 Answer

Player Falls Through Floor on Trigger 1 Answer

How to add rigidbody with script? 1 Answer

How do I "remove/disable" collision? 3 Answers

how to make an Explosive rigidbody trigger by another collision box 0 Answers

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