Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
BaseDeltaZero's avatar
BaseDeltaZero
Honored Guest
12 years ago

Look Flight Mechanics

Maybe someone clever can shed some light on how to implement something im wanting to test.

I have a Rigidbody with a nice force based flight script using the controller, say if i want it to switch over to a look based flight, how would i alter my script to apply relative torque based on moving my head?

here is what i have working with the controller

rigidbody.AddRelativeTorque(pitch*PitchSensitivity*Time.deltaTime

Cheers

4 Replies

Replies have been turned off for this discussion
  • Figure out if the camera is pointing in the same direction as the plane, and if not, figure out the angles. Use those to calculate how much torque should be applied to the plane, and use those floats in AddRelativeTorque(float x, float y, float z). That way the amount of torque increases when you move your head further away (If you're faster than the torque that is applied), and it max out at 90 degrees or something.
  • I understand the theory of what needs to be done, was hoping someone could help me express that in javascript.

    thanks anyway
  • In C#

    Quaternion head_tilt = Quaternion.identity;
    OVRDevice.GetOrientation(0, ref head_tilt);
    head_tilt.ToAngleAxis(out head_tilt_angle, out head_tilt_vector);

    out head_tilt_angle is a float i think, out head_tilt_vector is vector3 data, I think out head_tilt_vector.x is good head tilt info, print out the results when you tilt your head to see what you're working with.

    then just use head_tilt_vector values to determine head movement and apply those values to your torque function I guess.