Skip to content

Commit 5b7f9aa

Browse files
committed
fighter jet mass
1 parent 630eb22 commit 5b7f9aa

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

_notes/fighter-pete-plane.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ let control
4848
let throttle = 0
4949
let isAuthority = object.isAuthority()
5050

51+
let mass = 10
52+
5153
// create physics body
5254
const body = object.create('box')
5355
body.visible = false
5456
body.collision = isAuthority ? 'dynamic' : 'kinematic'
55-
body.collisionLayer = 'environment'
57+
body.collisionLayer = 'prop'
58+
body.mass = mass
5659
body.setSize(7, 1.1, 7)
5760
body.position.copy(object.position)
5861
body.position.y += 1
@@ -186,7 +189,7 @@ function fixedUpdate(delta) {
186189
if (isAuthority) {
187190
if (control) {
188191
// thrust
189-
_v1.copy(FORWARD).multiplyScalar(MAX_THRUST * throttle)
192+
_v1.copy(FORWARD).multiplyScalar(MAX_THRUST * throttle * mass)
190193
_v1.applyQuaternion(body.quaternion)
191194
body.addForce(_v1)
192195

@@ -221,11 +224,11 @@ function fixedUpdate(delta) {
221224
const velocityCorrection = _v2.subVectors(projVelocity, currVelocity)
222225

223226
// apply correction force (adjust the multiplier to control how quickly the plane aligns with its direction)
224-
const correctionMultiplier = 5 // You may need to adjust this value
227+
const correctionMultiplier = 5 * mass // You may need to adjust this value
225228
body.addForce(velocityCorrection.multiplyScalar(correctionMultiplier))
226229

227230
// upward lift
228-
const lift = 0.5
231+
const lift = 0.5 * mass
229232
const magnitude = body.getLinearVelocity().length()
230233
_v1.copy(UP).multiplyScalar(magnitude * lift)
231234
_v1.applyQuaternion(body.quaternion)

0 commit comments

Comments
 (0)