fixed bugs
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
||||
import { Box3, Object3D, Vector3 } from "three";
|
||||
import { Body } from "cannon-es";
|
||||
|
||||
const PLAYER_RADIUS = 0.3;
|
||||
const PLAYER_RADIUS = 0.5;
|
||||
|
||||
export type TriggerEventPayload = {
|
||||
lootableObject: Object3D;
|
||||
@@ -53,7 +53,7 @@ export class PhysicsTriggerC {
|
||||
lootableObject,
|
||||
triggerObject,
|
||||
center,
|
||||
radius: Math.max(size.x, size.y, size.z) / 2,
|
||||
radius: Math.max(size.x, size.z) / 2,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,9 +90,8 @@ export class PhysicsTriggerC {
|
||||
|
||||
for (const trigger of this.triggers) {
|
||||
const dx = playerBody.position.x - trigger.center.x;
|
||||
const dy = playerBody.position.y - trigger.center.y;
|
||||
const dz = playerBody.position.z - trigger.center.z;
|
||||
const distanceSq = dx * dx + dy * dy + dz * dz;
|
||||
const distanceSq = dx * dx + dz * dz;
|
||||
const isInside = distanceSq <= (trigger.radius + PLAYER_RADIUS) ** 2;
|
||||
const wasInside = this.activeTriggers.has(trigger);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user