File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -48,11 +48,14 @@ let control
48
48
let throttle = 0
49
49
let isAuthority = object . isAuthority ( )
50
50
51
+ let mass = 10
52
+
51
53
// create physics body
52
54
const body = object . create ( 'box' )
53
55
body . visible = false
54
56
body . collision = isAuthority ? 'dynamic' : 'kinematic'
55
- body . collisionLayer = 'environment'
57
+ body . collisionLayer = 'prop'
58
+ body . mass = mass
56
59
body . setSize ( 7 , 1.1 , 7 )
57
60
body . position . copy ( object . position )
58
61
body . position . y += 1
@@ -186,7 +189,7 @@ function fixedUpdate(delta) {
186
189
if ( isAuthority ) {
187
190
if ( control ) {
188
191
// thrust
189
- _v1 . copy ( FORWARD ) . multiplyScalar ( MAX_THRUST * throttle )
192
+ _v1 . copy ( FORWARD ) . multiplyScalar ( MAX_THRUST * throttle * mass )
190
193
_v1 . applyQuaternion ( body . quaternion )
191
194
body . addForce ( _v1 )
192
195
@@ -221,11 +224,11 @@ function fixedUpdate(delta) {
221
224
const velocityCorrection = _v2 . subVectors ( projVelocity , currVelocity )
222
225
223
226
// 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
225
228
body . addForce ( velocityCorrection . multiplyScalar ( correctionMultiplier ) )
226
229
227
230
// upward lift
228
- const lift = 0.5
231
+ const lift = 0.5 * mass
229
232
const magnitude = body . getLinearVelocity ( ) . length ( )
230
233
_v1 . copy ( UP ) . multiplyScalar ( magnitude * lift )
231
234
_v1 . applyQuaternion ( body . quaternion )
You can’t perform that action at this time.
0 commit comments