Car go wroom (bilen hopper mindre på jorden)
This commit is contained in:
35
Assets/Scripts/WheelControl.cs
Normal file
35
Assets/Scripts/WheelControl.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WheelControl : MonoBehaviour
|
||||
{
|
||||
public Transform wheelModel;
|
||||
|
||||
[HideInInspector] public WheelCollider WheelCollider;
|
||||
|
||||
// Create properties for the CarControl script
|
||||
// (You should enable/disable these via the
|
||||
// Editor Inspector window)
|
||||
public bool steerable;
|
||||
public bool motorized;
|
||||
|
||||
Vector3 position;
|
||||
Quaternion rotation;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
WheelCollider = GetComponent<WheelCollider>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
// Get the Wheel collider's world pose values and
|
||||
// use them to set the wheel model's position and rotation
|
||||
WheelCollider.GetWorldPose(out position, out rotation);
|
||||
wheelModel.transform.position = position;
|
||||
wheelModel.transform.rotation = rotation;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user