Help with drone fly controls #423
Answered
by
DavidBachmann
DavidBachmann
asked this question in
Q&A
-
Hello! I'm playing around with this tremendous tool trying to make a drone fly half-realistically. In this video I show how pitching only works when going straight: // Lift
api.applyLocalForce([0, lift.current, 0], [0, 0, 0]);
// Yaw
api.angularVelocity.set(0, yaw.current, 0);
// Pitch and roll
api.applyTorque([
pitch.current,
0, // Using angular velocity for yaw
roll.current,
]); Edit: Solved below |
Beta Was this translation helpful? Give feedback.
Answered by
DavidBachmann
Dec 31, 2022
Replies: 1 comment
-
Sometimes all you need is a good night's sleep.
const unitVector = new THREE.Vector3();
const unitQuaternion = new THREE.Quaternion();
const quaternion = useRef<Quad>([0, 0, 0, 1]);
api.quaternion.subscribe((val) => (quaternion.current = val)); const qc = quaternion.current;
const q = unitQuaternion.set(qc[0], qc[1], qc[2], qc[3]);
const v = unitVector.set(
pitch.current * torqueScale, 0,roll.current * torqueScale
);
v.applyQuaternion(q);
api.applyTorque(v.toArray()); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
DavidBachmann
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sometimes all you need is a good night's sleep.