Beispiel #1
0
    private void LateUpdate()
    {
        Vector3 pos = transform.position = aircraft.position.GetUnityEngineVector3();

        transform.localEulerAngles = aircraft.rotation.GetUnityEngineVector3();
        PhysicsEngineForFun.Vector3 offset = new PhysicsEngineForFun.Vector3(4.0f + aircraft.velocity.GetUnityEngineVector3().magnitude, 0, 0);
        offset = aircraft.transformMatrix.TransformDirection(offset);
        Camera.main.transform.position = new Vector3(pos.x + 4.0f + offset.x, pos.y + 5.0f, pos.z + offset.z);
        Vector3 forward = pos - Camera.main.transform.position;

        forward.Normalize();
        if (forward == Vector3.zero)
        {
            return;
        }
        Camera.main.transform.rotation = Quaternion.LookRotation(forward);
    }
Beispiel #2
0
    private void FixedUpdate()
    {
        windSpeed = windSpeed * 0.9f + new Vector3(Random.Range(0, 0.1f), 0, Random.Range(0, 0.1f));

        PhysicsEngineWindSpeed.x = windSpeed.x;
        PhysicsEngineWindSpeed.y = windSpeed.y;
        PhysicsEngineWindSpeed.z = windSpeed.z;

        sailboat.ClearAccumulator();
        PhysicsEngineForFun.Vector3 propulsion = new PhysicsEngineForFun.Vector3(-10.0f, 0, 0);
        propulsion = sailboat.transformMatrix.TransformDirection(propulsion);

        sailboat.AddForce(propulsion);

        registry.UpdateForces(0.02f);

        sailboat.Integrate(0.02f);

        showSailboatVelocity = sailboat.velocity.GetUnityEngineVector3();
    }
Beispiel #3
0
    private void FixedUpdate()
    {
        PhysicsEngineWindSpeed.x = windSpeed.x;
        PhysicsEngineWindSpeed.y = windSpeed.y;
        PhysicsEngineWindSpeed.z = windSpeed.z;

        aircraft.ClearAccumulator();
        PhysicsEngineForFun.Vector3 propulsion = new PhysicsEngineForFun.Vector3(-10.0f, 0, 0);
        propulsion = aircraft.transformMatrix.TransformDirection(propulsion);

        aircraft.AddForce(propulsion);

        registry.UpdateForces(0.02f);

        aircraft.Integrate(0.02f);

        if (aircraft.position.y < 0)
        {
            aircraft.position.y = 0;
        }

        showAircraftVelocity = aircraft.velocity.GetUnityEngineVector3();
    }