using System.Collections; using System.Collections.Generic; using UnityEngine; public class ShipMoveSides : MonoBehaviour { [SerializeField] private float _radius; [SerializeField] [Range(-1,1)] private float _value; [SerializeField] private float _speed; [SerializeField] private float _rollAngle = 45; public float Radius => _radius; private void Update() { ApplyMovement(); } public void UpdateInput(float val) { _value = -val; } private void ApplyMovement() { var newPos = transform.localPosition + _value * Vector3.right; newPos.x = Mathf.Clamp(newPos.x, -_radius, _radius); transform.localPosition = Vector3.Lerp(transform.localPosition, newPos, Time.deltaTime * _speed); transform.localRotation = Quaternion.Euler(new Vector3(0, 0, _value * -_rollAngle)); } }