Witam, mam problem, napisałem kod na poruszanie się lufy czołgu w C# i zastanawiam się czy w jakikolwiek sposób można dodać ogranicznik rotacji.
(np. lufa zostaje skierowana w górę tylko do 120 stopni)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class lufa : MonoBehaviour
{
[Range(0f, 50f)] public float obrot = 50.0f;
[Range(0f, 50f)] public float kontra = 0.3f;
void Start()
{
}
void Update()
{
transform.Rotate(Vector3.right * Input.GetAxis("Horizontallufa") * obrot * Time.deltaTime);
transform.Translate(Vector3.forward * Input.GetAxis("Horizontallufa") * kontra * Time.deltaTime);
}
}