I'm trying to think of practical examples of when one of these is correct over the other.
If this is being used for a physics-type behaviour, and my objects objects are solid then IsOverlapping should never be true.
If I am mimicking a coin collecting scenario (e.g. Super Mario Bros.), then they should be the same, but if the engine is slow and misses the OnCollision event then I guess it would be possible to be overlapping.
Is it fair to say, always use OnOverlapping, as this will not suffer from the case of an OnCollision getting missed?
If not, could anyone suggest practical examples of when one would be correct and the other incorrect?
NB: I'm assuming that it is possible for an OnCollision to be missed due the underlying engine's timings. I could be wrong.
on collision is detected whenever it happens, not just when objects collide with their edges.. for example you have an object. then create another one on top.. on collision will trigger. but it won't in the case that they were already overlapping, for example... two objects are overlapping.. and your event goes.. A on collision with B, if A.variable is 1... /// if your A object was overlapping B, no matter when you change the variable, the collision won't trigger since they were overlapping before that
Develop games in your browser. Powerful, performant & highly capable.
and plus, even if your objects are solids the might overlap, specially if they are moving fast. if they bounce you may not notice, but if they are suposed to stop on collision, you will see sometimes the overlap some pixels, or there is a small gap between the objects