Hi.
I’ve recently started to make my own flying game. So at first things went smoothly, as I can control the plane in terms of pitch, yaw and roll. However, things went awry when I tried to simulate lift. The intention is that lift should give the plane thrust in its own relative Y coordinate, as it is in real life. However, for some reason, it makes the plane fly upwards in its global direction, which is just wrong. Any ideas?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlanePhysics : MonoBehaviour {
public float thrust;
public Rigidbody rb;
public float liftfactor;
public float lift;
public float PitchForce;
public float YawForce;
public float RollForce;
float speed;
void Start() {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate() {
rb.AddRelativeForce(Vector3.forward * thrust);
rb.AddForce(Vector3.up * lift);
float yaw = Input.GetAxis("Yaw");
rb.AddTorque(transform.up * YawForce * yaw);
float roll = Input.GetAxis("Roll");
rb.AddTorque(transform.forward * RollForce * roll);
float pitch = Input.GetAxis("Pitch");
rb.AddTorque(transform.right * PitchForce * pitch);
}
}