Go Back   Physics Help Forum > Physics Forums > Physics

Physics Physics Forum - General Physics Discussion and Physics News

LinkBack Thread Tools Display Modes
Old Jan 2nd 2018, 01:42 AM   #1
Junior Member
Join Date: Nov 2016
Posts: 4
OnCollisionEnter inconsistent - how does it work exactly?


I always thought I knew how the OnCollision functions worked - after all I did my research. But I ran into some weird issue in a recent project of mine. First of all, I'm using Unity 2017.1 if that's relevant, in case this is a known issue regarding this particular release.

Now in order for collision events to trigger, one of the colliding objects needs a non-kinematic rigidbody attached, right? - emphasis on "one of the objects". I gave my player objects a non-kinematic rigidbody (freezing position and rotation, as I control them manually) and these players check for bullet collisions using OnCollisionEnter. The bullets don't have any rigidbodies attached.

Now, I noticed that when I shoot bullets at a player (that isn't even moving at all), the bullets, regardless of how fast they move, sometimes hit the player, and sometimes don't. As if it was random. As soon as I attach a rigidbody to the bullets too, however, the collisions work consistently.

I've never attached rigidbodies to both colliding objects before, and so far that's always worked out for me, but in this case it didn't. Am I missing something?

The player had a box collider, the bullet a sphere collider and the fixed timestep was 0.02 if I remember correctly. I'd really like some insight as to why this happens. Hope someone has the answer
johnsmith is offline   Reply With Quote

  Physics Help Forum > Physics Forums > Physics

inconsistent, oncollisionenter, work

Thread Tools
Display Modes

Similar Physics Forum Discussions
Thread Thread Starter Forum Replies Last Post
Positive work where negative work should be assaftolko Electricity and Magnetism 6 Mar 25th 2013 11:50 AM
Work HW Problem (Work done on block and spring system) SMA777 Energy and Work 0 Oct 15th 2011 05:49 PM

Facebook Twitter Google+ RSS Feed