Question by
GameDeveloperAf · Nov 15, 2020 at 05:48 PM ·
raycastvibrationhit.pointvibratesurface normal
Get Ground Normal For Vehicle but there is an issue when it is on the edge of the surface
Hello. There is a problem with Surface Alignment on the Edges. I want to get ground normal for my vehicle but there is an issue when it is on the edge of the surface. Watch the video to understand what is about the problem https://www.youtube.com/watch?v=dVQmHlpT11Y. You can see the issue on the 0:40 seconds of the video.
There is not problem with code. Just there is a problem when my vehicle is on the edge of the surface then my vehicle is starting vibrating like in the video. Is there any solution to fix this issue.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Example: MonoBehaviour
{
void Update()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, -transform.up, out hit))
{
transform.rotation = Quaternion.FromToRotation(transform.up, hit.normal) * transform.rotation;
}
}
Comment
Your answer
Follow this Question
Related Questions
Raycast targets to origin 0 Answers
SphereCastAll hit.point are allways zero 1 Answer
hit.point returns wrong coordinates 0 Answers
Raycast Hit suddently stopped working 0 Answers