character collider fix
This commit is contained in:
@@ -26,10 +26,10 @@ export class CharacterControls {
|
||||
this.characterController.setUp({x:0, y:1, z:0});
|
||||
po.rigidBody.setTranslation(this.model.position)
|
||||
po.characterController = this.characterController;
|
||||
// this.characterController.enableSnapToGround(0.5);
|
||||
//this.characterController.enableSnapToGround(0.5);
|
||||
// // Don’t allow climbing slopes larger than 45 degrees.
|
||||
// this.characterController.setMaxSlopeClimbAngle(45 * Math.PI / 180);
|
||||
// // Automatically slide down on slopes smaller than 30 degrees.
|
||||
// Automatically slide down on slopes smaller than 30 degrees.
|
||||
// this.characterController.setMinSlopeSlideAngle(30 * Math.PI / 180);
|
||||
// this.characterController.enableAutostep(0.5, 0.2, true);
|
||||
this.characterController.setApplyImpulsesToDynamicBodies(true);
|
||||
|
||||
+2
-3
@@ -30,10 +30,10 @@ class Hero{
|
||||
|
||||
let bb = getBoundingBox(this.model);
|
||||
let size = getBoundingBoxSize(bb);
|
||||
let center = getBoundingBoxCenterPoint(bb, this.model.position).negate();
|
||||
let center = getBoundingBoxCenterPoint(bb, this.model.position)
|
||||
|
||||
let po = gameEngine.physics.add(this.model, 'kinematicPositionBased', false, undefined, 'capsule', { radius: size.x/2, halfHeight: size.y/2})
|
||||
po.collider.setTranslationWrtParent({x: center.x, y: -this.model.position.y, z: center.z});
|
||||
po.collider.setTranslationWrtParent({x: center.x, y: center.y + size.y/2, z: center.z});
|
||||
//po.collider.setActiveEvents(RAPIER.ActiveEvents.COLLISION_EVENTS);
|
||||
|
||||
this.characterControls = new CharacterControls(this.model,
|
||||
@@ -50,7 +50,6 @@ class Hero{
|
||||
}
|
||||
|
||||
update(){
|
||||
//return
|
||||
if (this.gameEngine.renderer.xr.isPresenting) return;
|
||||
|
||||
if (this.ready && !this.disableInput) {
|
||||
|
||||
+3
-2
@@ -65,8 +65,9 @@ export default {
|
||||
if (transformFn){
|
||||
value = transformFn(key, value)
|
||||
}
|
||||
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
||||
this.deepMerge(target[key] = target[key] || {}, value, transformFn);
|
||||
if (value && typeof value === 'object') {
|
||||
let dflt = Array.isArray(value) ? [] : {};
|
||||
this.deepMerge(target[key] = target[key] || dflt, value, transformFn);
|
||||
return;
|
||||
}
|
||||
target[key] = value;
|
||||
|
||||
@@ -126,6 +126,14 @@ export default {
|
||||
if (this.scene.data.$scene){
|
||||
let env = await gameEngine.load(this.scene.data.$scene.asset.name);
|
||||
this.setObjectAttributes(l, this.scene.data, env.scene, env, 100);
|
||||
if (this.env != 'GameDesigner'){
|
||||
env.scene.traverse(o=>{
|
||||
if (o.name == 'Sphere'){
|
||||
console.log('Fixing ground. TODO!!!')
|
||||
gameEngine.physics.add(o, 'fixed', true, undefined)
|
||||
}
|
||||
})
|
||||
}
|
||||
gameEngine.activeObjects.add(env.scene);
|
||||
}
|
||||
if (this.scene.data.$intro && this.env == 'GamePlaying'){
|
||||
|
||||
Reference in New Issue
Block a user