Hi Unity Community ,
I’m currently developing a small game , in which you can fly an Aircraft.
To create a realistic flight.model I tried using rigidbody , but it didn’t work out as I planned.
Without the rigidbody I can’t simulate a glide slope and acceleration to a maxSpeed properly , so I came here to ask for help.
Down below is the code I’m using currently.
I really appreciate all help I can get.
using UnityEngine;
using System.Collections;
public class RealisticPlane : MonoBehaviour {
public float maxSpeed = 10;
public float maxLift = 5;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
transform.Rotate ( Input.GetAxis ("Vertical") , Input.GetAxis("RollAxis") , -Input.GetAxis ("Horizontal"));
if (Input.GetKey (KeyCode.W))
{
transform.Translate(Vector3.forward * Time.deltaTime * maxSpeed);
}
float heightPosition = Terrain.activeTerrain.SampleHeight (transform.position);
if (heightPosition > transform.position.y)
{
transform.position = new Vector3 (transform.position.x,
heightPosition,
transform.position.z);
}
}
}