Ejemplo n.º 1
0
    private void SetupThruster(ThrusterController con)
    {
        if (thrusterList.Contains (con))
            return;

        if((con as CMGController) != null)
        {
            thrusterForce[con] = Vector3.zero; // Ignore force and position.
            thrusterPosition[con] = Vector3.zero;
            thrusterMoment[con] = (con as CMGController).GetMaxPower()*ship.transform.InverseTransformDirection(con.transform.up);
        }
        else
        {
            thrusterForce[con] = (ship.transform.InverseTransformDirection(con.transform.FindChild("Jet").forward*(-1)) )*con.GetMaxPower();
            thrusterPosition[con] = ship.transform.InverseTransformPoint(con.transform.FindChild("Jet").position); // Relative position of the force vector
            thrusterMoment[con] = Vector3.Cross(thrusterForce[con],thrusterPosition[con]);
        }
        thrusterAccLinear[con] = thrusterForce[con] / ship.GetComponent<Rigidbody>().mass;
        thrusterAccAngular[con] = thrusterMoment[con] / ship.GetComponent<Rigidbody>().mass;
        thrusterPower[con] = 0f; // power between zero and one
        thrusterList.Add (con);
    }