Fix collision detection issues
This commit is contained in:
parent
3c5d87a98b
commit
6d6284f717
6 changed files with 40 additions and 39 deletions
|
|
@ -17,7 +17,7 @@ export class Camera extends GameObject {
|
|||
super();
|
||||
|
||||
this.boundingBox = new BoundingBox(null);
|
||||
physics.addDynamicBoundingBox(this.boundingBox);
|
||||
//physics.addDynamicBoundingBox(this.boundingBox);
|
||||
|
||||
this.addCommandExecutor(BeforeRenderCommand, this.draw.bind(this));
|
||||
this.addCommandExecutor(MoveToCommand, this.moveTo.bind(this));
|
||||
|
|
|
|||
|
|
@ -43,17 +43,13 @@ export class Character extends GameObject {
|
|||
const nextPrimitive = this.primitive.clone();
|
||||
nextPrimitive.center = value;
|
||||
|
||||
console.log(this.physics
|
||||
.findIntersecting(nextPrimitive.boundingBox)
|
||||
.filter(b => b.value)
|
||||
.map((b) => b.value.distance(nextPrimitive.center) + 2 * nextPrimitive.radius)
|
||||
)
|
||||
|
||||
if (
|
||||
this.physics
|
||||
.findIntersecting(nextPrimitive.boundingBox)
|
||||
.filter(b => b.value)
|
||||
.map((b) => b.value.distance(nextPrimitive.center) + 2 * nextPrimitive.radius)
|
||||
.filter((b) => b.value)
|
||||
.map(
|
||||
(b) => b.value.distance(nextPrimitive.center) + nextPrimitive.radius
|
||||
)
|
||||
.find((d) => d < 0) !== undefined
|
||||
) {
|
||||
this.setPosition(value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue