Crossy_Road_VR/Assets/Crossy Road VR/Scripts/CarControllerScript.cs

49 lines
943 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Скрипт для анимации машины
/// </summary>
public class CarControllerScript : MonoBehaviour
{
/// <summary>
/// to do
/// </summary>
[SerializeField]
private List<GameObject> _Wheels = new List<GameObject>();
/// <summary>
/// to do
/// </summary>
[SerializeField]
private int _Speed;
/// <summary>
/// высота,чтобы колёса стояли на 0
/// </summary>
[SerializeField]
private float _High;
public float High
{
get => _High;
set => _High = value;
}
private void Start()
{
_High = gameObject.transform.position.y;
}
private void FixedUpdate()
{
foreach (var wheel in _Wheels)
{
wheel.transform.Rotate(Vector3.right * _Speed);
}
}
}