- Home /
Question by
GameDeveloperAf · Nov 27, 2020 at 08:41 PM ·
raycastsmoothhithit.point
Raycast smooth rotation and distance
hi
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Vehicle : MonoBehaviour
{
RaycastHit frontRightRaycast, frontLeftRaycast, backRightRaycast,
backLeftRaycast;
void Update()
{
if (Physics.Raycast(transform.position + new Vector3(0.5f, -0.75f, 1), Vector3.down, out frontRightRaycast))
{
Physics.Raycast(transform.position + new Vector3(-0.5f, -0.75f, 1), Vector3.down, out frontLeftRaycast);
Physics.Raycast(transform.position + new Vector3(0.5f, -0.75f, -1), Vector3.down, out backRightRaycast);
Physics.Raycast(transform.position + new Vector3(-0.5f, -0.75f, -1), Vector3.down, out backLeftRaycast);
// What to do here to rotate the vehicle case smoothly on the x and
// z rotation axis only. I don't want to change the y axis for rotation. And keep the fixed
// distance between ground and vehicle
}
}
}
Comment
Your answer
Follow this Question
Related Questions
rayCastHit question 1 Answer
RaycastHit Collider Question 1 Answer
What are the hit coordinates from raycasting? 1 Answer
Vertical auto-aim with raycasts 1 Answer
Detemine wich side of a cube was hit 1 Answer