Как сделать управление самолетом кнопками?

Форум для самых маленьких, а так же тех, кому недосуг читать справку самостоятельно.

Как сделать управление самолетом кнопками?

Сообщение Romai25245 12 янв 2021, 17:24

Как сделать управление самолетом кнопками?
вот скрипт управлением самолетом:


using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;

namespace UnityStandardAssets.Vehicles.Aeroplane
{
[RequireComponent(typeof (AeroplaneController))]
public class AeroplaneUserControl4Axis : MonoBehaviour
{

public float maxRollAngle = 80;
public float maxPitchAngle = 80;






private AeroplaneController m_Aeroplane;
private float m_Throttle;
private bool m_AirBrakes;
private float m_Yaw;


private void Awake()
{

m_Aeroplane = GetComponent<AeroplaneController>();
}


private void FixedUpdate()
{

float roll = CrossPlatformInputManager.GetAxis("Horizontal");
float pitch = -CrossPlatformInputManager.GetAxis("Vertical");
m_AirBrakes = CrossPlatformInputManager.GetButton("Fire1");
m_Yaw = CrossPlatformInputManager.GetAxis("Horizontal");
m_Throttle = CrossPlatformInputManager.GetAxis("Vertical");

AdjustInputForMobileControls(ref roll, ref pitch, ref m_Throttle);


m_Aeroplane.Move(roll, pitch, m_Yaw, m_Throttle, m_AirBrakes);
}


private void AdjustInputForMobileControls(ref float roll, ref float pitch, ref float throttle)
{




float intendedRollAngle = roll*maxRollAngle*Mathf.Deg2Rad;
float intendedPitchAngle = pitch*maxPitchAngle*Mathf.Deg2Rad;
roll = Mathf.Clamp((intendedRollAngle - m_Aeroplane.RollAngle), -1, 1);
pitch = Mathf.Clamp((intendedPitchAngle - m_Aeroplane.PitchAngle), -1, 1);
}
}
}
Romai25245
UNец
 
Сообщения: 3
Зарегистрирован: 09 янв 2021, 19:27

Вернуться в Почемучка

Кто сейчас на конференции

Сейчас этот форум просматривают: Google [Bot] и гости: 20