Question by
kirstenlyra · Nov 17, 2019 at 06:23 PM ·
not workingplaneturning
Airplane doesn't work properly.,Airplane doesn't work properly
I have a plane script and it works. The only problem that i have is if i rotate to the sides, it keeps going forward. Does anyone have a solution? This is what i've got so far:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class PlanePilot : MonoBehaviour { private Transform Player; private Transform respawnPoint;
public GameObject crashEffect;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.position += transform.forward * Time. deltaTime * 50.0f;
transform.Rotate( Input.GetAxis("Vertical"), 0.0f, -1.0f*Input.GetAxis("Horizontal") );
float terrainHeigtWhereWeAre = Terrain.activeTerrain.SampleHeight(transform.position);
if(terrainHeigtWhereWeAre > transform.position.y)
{
Crash();
}
}
thanks!
Comment