0 votes
by
edited by
Hi,

I have several cars on the scene. I am processing the OnImpact  event to hand out damage in case of collision. I subscribe to the event handler with

_vpp.onImpact += Car_OnImpact;

When the method is invoked by VPP inside Car_OnImpact() often (but not always) the VPVehicleController.isCollisionEnter returns false, although it is the initial contact with another car. Am I doing something wrong?

1 Answer

0 votes
by
selected by
 
Best answer

The value VPVehicleController.isCollisionEnter is used when subscribing to VPVehicleController.onRawImpact. Otherwise its value is undetermined. onRawImpact simply forwards the events OnCollisionEnter and OnCollisionStay generated by the rigidbody.

VPVehicleController.onImpact is different. This event compiles the positions and velocities of a number the contact points along several OnCollisionEnter/OnCollisionStay events, then raises timed onImpact events from FixedUpdate. These "managed" impacts are much more convenient for audio effects, visual effects, damage, etc than using the raw collision events. This is especially relevant on high physics rates, where 100's of OnCollision events may happen in a very short time.

by
Hi Edy, thank you for the clarification!
...