Hello,
I have posted on Unity answers a few days ago, but I think it got lost in the sea of other questions, so I thought of moving my questions to the forum. I hope it is okay (original: https://answers.unity.com/questions/1800212/wheel-colliders-and-continuous-ground-hit.html).
I have a problem with continuously detecting a ground hit from a wheel collider. I am creating splashing effects where a car drives into a puddle and the water stirs up (using the custom render texture, I am drawing a point where the car hits the texture and using a wave equation I spread it into a ripple).
When the car drives slowly the wave follows where the tire has been, however, when the car drives fast enough, artefacts start to appear - the ground hit is not continuous, leaving a few ripples here and there which is not what I want.
Is there a way to deal with this? Right now I am drawing a line between two hit points, but I would like to know if there is a better solution.
The shortened code:
void Update()
{
if (wheelCollider.GetGroundHit(out WheelHit hit))
{
//contact point is created if wheel hits the road
if (hit.collider.gameObject.layer == roadLayer)
{
Vector3 hitPoint = hit.point + (car.velocity * (Time.deltaTime));
//... create ripple at this position...
}
}
}