@@ -135,10 +135,10 @@ class MainScene extends Scene3D {
135135 */
136136 this . add . existing ( this . man )
137137 this . physics . add . existing ( this . man , {
138- shape : 'cylinder ' ,
138+ shape : 'capsule ' ,
139139 radius : 0.3 ,
140- height : 1 ,
141- offset : { y : - .5 }
140+ height : 0.4 ,
141+ offset : { y : - 0 .5 }
142142 } )
143143 this . man . body . setFriction ( 0.8 )
144144 this . man . body . setAngularFactor ( 0 , 0 , 0 )
@@ -292,41 +292,43 @@ class MainScene extends Scene3D {
292292 /**
293293 * Player Move
294294 */
295- if ( this . keys . w . isDown || this . keys . a . isDown || this . keys . s . isDown || this . keys . d . isDown || this . move ) { // Run Forwards or backwards
295+ if ( this . keys . w . isDown || this . keys . a . isDown || this . keys . s . isDown || this . keys . d . isDown || this . move ) {
296+ // Run Forwards or backwards
296297 if ( this . man . animation . current === 'idle' && this . canJump ) this . man . animation . play ( 'run' )
297298
298- if ( this . keys . s . isDown ) { //Backwards/diagonal movement
299+ if ( this . keys . s . isDown ) {
300+ //Backwards/diagonal movement
299301 speed *= - 1
300302 this . man . animation . mixer . timeScale = - 1
301- if ( this . keys . a . isDown ) {
302- theta -= Math . PI / 4
303- } else if ( this . keys . d . isDown ) {
304- theta += Math . PI / 4
303+ if ( this . keys . a . isDown ) {
304+ theta -= Math . PI / 4
305+ } else if ( this . keys . d . isDown ) {
306+ theta += Math . PI / 4
305307 }
306- } else if ( this . keys . w . isDown ) { // Forwards / Diagonal movement
308+ } else if ( this . keys . w . isDown ) {
309+ // Forwards / Diagonal movement
307310 this . man . animation . mixer . timeScale = 1
308- if ( this . keys . a . isDown ) {
309- theta += Math . PI / 4
310- } else if ( this . keys . d . isDown ) {
311- theta -= Math . PI / 4
311+ if ( this . keys . a . isDown ) {
312+ theta += Math . PI / 4
313+ } else if ( this . keys . d . isDown ) {
314+ theta -= Math . PI / 4
312315 }
313- } else if ( this . keys . a . isDown ) {
314- theta += Math . PI / 2
315- } else if ( this . keys . d . isDown ) {
316- theta -= Math . PI / 2
316+ } else if ( this . keys . a . isDown ) {
317+ theta += Math . PI / 2
318+ } else if ( this . keys . d . isDown ) {
319+ theta -= Math . PI / 2
317320 }
318321
319322 const x = Math . sin ( theta ) * speed ,
320323 y = this . man . body . velocity . y ,
321324 z = Math . cos ( theta ) * speed
322325
323326 this . man . body . setVelocity ( x , y , z )
324- }
325- else {
327+ } else {
326328 if ( this . man . animation . current === 'run' && this . canJump ) {
327- this . man . animation . play ( 'idle' )
328- this . man . animation . mixer . timeScale = 1
329- }
329+ this . man . animation . play ( 'idle' )
330+ this . man . animation . mixer . timeScale = 1
331+ }
330332 }
331333
332334 /**
0 commit comments