2021-01-07 06:44:42 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2021-01-10 06:55:45 +01:00
|
|
|
using Ktyl.Util;
|
2021-01-07 06:44:42 +01:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
[RequireComponent(typeof(Renderer))]
|
|
|
|
public class ShipGraphics : MonoBehaviour
|
|
|
|
{
|
2021-01-10 06:55:45 +01:00
|
|
|
[SerializeField] private Transform _ship;
|
|
|
|
[SerializeField] private SerialFloat _horizontalInput;
|
|
|
|
|
|
|
|
[SerializeField] private SerialFloat _distanceSinceLastBeat;
|
|
|
|
[SerializeField] private float _bounce;
|
|
|
|
|
|
|
|
[SerializeField] private float _maxTilt;
|
|
|
|
[Range(0, 100)] [SerializeField] private float _tiltSensitivity;
|
|
|
|
|
2021-01-07 06:44:42 +01:00
|
|
|
private Renderer _renderer;
|
2021-01-10 06:55:45 +01:00
|
|
|
private float _tilt;
|
2021-01-07 06:44:42 +01:00
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
_renderer = GetComponent<Renderer>();
|
|
|
|
}
|
2021-01-10 06:55:45 +01:00
|
|
|
|
|
|
|
private void LateUpdate()
|
|
|
|
{
|
|
|
|
var targetRotationAngle = _maxTilt * _horizontalInput;
|
|
|
|
_tilt = Mathf.Lerp(_tilt, targetRotationAngle, _tiltSensitivity * Time.deltaTime);
|
|
|
|
|
|
|
|
var rot = Quaternion.Euler(0, 0, -_tilt);
|
|
|
|
transform.rotation = rot;
|
|
|
|
|
|
|
|
transform.position = _ship.position + Vector3.up * _distanceSinceLastBeat * _bounce;
|
|
|
|
}
|
2021-01-07 06:44:42 +01:00
|
|
|
}
|