DroneSimulator/Assets/Scripts/Drone/Motor.cs

42 lines
758 B
C#

using UnityEngine;
public class Motor : MonoBehaviour
{
[SerializeField] private float _maxThrust;
[SerializeField] private float _thrust;
[SerializeField] private Rigidbody _drone;
private Transform _transform;
private void Awake()
{
_transform = transform;
}
private void FixedUpdate()
{
_drone.AddForceAtPosition(_transform.right.normalized * _thrust, _transform.position, ForceMode.Force);
}
public void SetThrust(float value)
{
_thrust = value * _maxThrust;
}
public void Blyat(float value)
{
if (value < _maxThrust)
{
_thrust = value;
}
else
{
_thrust = _maxThrust;
}
}
}