- Home /
Vehicle is vibrating on the edge of the ramp/surface when I get the normal of the surface
I want to make a game about cars. But I don't want to use the default physics of the unity engine because of the issues of the physics in the unity engine. And I want to make my own gravity and wheel collider for my vehicle using raycast and get the surface normal. For this I get the surface normal using raycast to make my own wheel collider and gravity without using rigidbody. I can get ground normal, it is ok. But when my vehicle/object/player come to the edge of the ramp/ground, then my vehicle is beginning to vibrate on that edge. THE ISSUE IS MY VEHICLE IS VIBRATING ON THE EDGE OF THE RAMP/SURFACE. How can I solve this issue. Please help me to solve this. I need urgent help. You can take a look at the video to understand well if you want to know what the problem is about. The issue occurs at 0:40 seconds of the video. https://www.youtube.com/watch?v=dVQmHlpT11Y
The code is ok. But I think that I need to write some functions to fix this issue but I could not find how to solve this issue. I do not want that my vehicle vibrate on the edge when I get the ground normal for my vehicle. As you can see that my vehicle is vibrating in the edge of the ramp/ground in the video. How can I solve this issue.
void Update()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, -transform.up, out hit))
{
transform.rotation = Quaternion.FromToRotation(transform.up,
hit.normal) * transform.rotation;
}
}