Hi,
I want to check if any of the contact points of a collision are below a certain y coordinate.
I just don’t exactly know how to do that.
I looked up how to check an Array for certain values, but with the contactpoints you have to do like:
other.contacts[0].point.y
And I also couldn’t find how to check if it is below a value, only if it has a point has the exact value.
I realized, that when the object is not changing its state (eg. Position) It does not show me any Contact points.
Can I manually check for Contact points, in case it is not moving?
Theses are events and are not called every frames.
OnCollisionEnter will be called when the collision begin.
OnCollisionStay will be called every FixedDeltaTime (not every frame) while a collision exist.
OnCollisionExit will be called when the collision end.
Physics is not computed each frame but in a fixed Timestep you can configure yourself in Edit->Projects Settings->Time
By default it’s 0.02 (50 fps)
It’s fixed because a game’s framerate is very inconsistant and collision bugs can occure easely when the framerate drop slightly. It’s even worst with Vertical Sync.
By configuring a fixed timestep you are aware of the limitation you have to avoid collisions bugs.
Do not try to collide a car moving at 1000 km/h against a thin wall, it will just pass trough.
Imagine the fact that if the car is at 999 km/h, the detection will occure but not at 1000 km/h.
Changing the fixed timestep allow you to tweak that.
You still have to keep in mind that a lower fixed timestep take more CPU. (0.01 → 100 FPS)