45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace ARTNGAME.Skymaster
|
|
{
|
|
[RequireComponent(typeof(AeroplaneControllerSM))]
|
|
public class AeroplaneUserControl4AxisSM : MonoBehaviour
|
|
{
|
|
public float maxRollAngle = 80f;
|
|
|
|
public float maxPitchAngle = 80f;
|
|
|
|
private AeroplaneControllerSM m_Aeroplane;
|
|
|
|
private float m_Throttle;
|
|
|
|
private bool m_AirBrakes;
|
|
|
|
private float m_Yaw;
|
|
|
|
private void Awake()
|
|
{
|
|
m_Aeroplane = GetComponent<AeroplaneControllerSM>();
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
float axis = Input.GetAxis("Mouse X");
|
|
float axis2 = Input.GetAxis("Mouse Y");
|
|
m_AirBrakes = Input.GetButton("Fire1");
|
|
m_Yaw = Input.GetAxis("Horizontal");
|
|
m_Throttle = Input.GetAxis("Vertical");
|
|
m_Aeroplane.Move(axis, axis2, m_Yaw, m_Throttle, m_AirBrakes);
|
|
}
|
|
|
|
private void AdjustInputForMobileControls(ref float roll, ref float pitch, ref float throttle)
|
|
{
|
|
float num = roll * maxRollAngle * (MathF.PI / 180f);
|
|
float num2 = pitch * maxPitchAngle * (MathF.PI / 180f);
|
|
roll = Mathf.Clamp(num - m_Aeroplane.RollAngle, -1f, 1f);
|
|
pitch = Mathf.Clamp(num2 - m_Aeroplane.PitchAngle, -1f, 1f);
|
|
}
|
|
}
|
|
}
|