40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace ARTNGAME.Skymaster
|
|
{
|
|
[RequireComponent(typeof(AeroplaneControllerSM))]
|
|
public class AeroplaneUserControl2AxisSM : MonoBehaviour
|
|
{
|
|
public float maxRollAngle = 80f;
|
|
|
|
public float maxPitchAngle = 80f;
|
|
|
|
private AeroplaneControllerSM m_Aeroplane;
|
|
|
|
private void Awake()
|
|
{
|
|
m_Aeroplane = GetComponent<AeroplaneControllerSM>();
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
float axis = Input.GetAxis("Horizontal");
|
|
float axis2 = Input.GetAxis("Vertical");
|
|
bool button = Input.GetButton("Fire1");
|
|
float throttleInput = ((!button) ? 1 : (-1));
|
|
m_Aeroplane.Move(axis, axis2, 0f, throttleInput, button);
|
|
}
|
|
|
|
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);
|
|
float num3 = throttle * 0.5f + 0.5f;
|
|
throttle = Mathf.Clamp(num3 - m_Aeroplane.Throttle, -1f, 1f);
|
|
}
|
|
}
|
|
}
|