Skip to content

Commit 97bb12a

Browse files
fix: sensor collider bug
1 parent 317b22c commit 97bb12a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ecctrl",
3-
"version": "1.0.32",
3+
"version": "1.0.33",
44
"author": "Erdong Chen",
55
"license": "MIT",
66
"description": "A floating rigibody character controller for R3F",

src/Ecctrl.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,14 @@ export default function Ecctrl({
734734
rayHit = world.castRay(
735735
rayCast,
736736
rayLength,
737-
false,
737+
true,
738738
null,
739739
null,
740740
// I have no idea
741-
characterRef.current as unknown as Collider
741+
characterRef.current as unknown as Collider,
742+
null,
743+
// this exclude with sensor collider
744+
((collider) => !collider.isSensor())
742745
);
743746
/**Test shape ray */
744747
// rayHit = world.castShape(
@@ -772,7 +775,6 @@ export default function Ecctrl({
772775
rayOrigin.y - rayHit.toi,
773776
rayOrigin.z
774777
);
775-
// this deals with any invisible collider object (sensor or air wall)
776778
const rayHitObjectBodyType = rayHit.collider.parent().bodyType();
777779
const rayHitObjectBodyMass = rayHit.collider.parent().mass();
778780
// Body type 0 is rigid body, body type 1 is fixed body, body type 2 is kinematic body
@@ -845,11 +847,14 @@ export default function Ecctrl({
845847
slopeRayHit = world.castRay(
846848
slopeRayCast,
847849
slopeRayLength,
848-
false,
850+
true,
849851
null,
850852
null,
851853
// Still no idea
852-
characterRef.current as unknown as Collider
854+
characterRef.current as unknown as Collider,
855+
null,
856+
// this exclude with sensor collider
857+
((collider) => !collider.isSensor())
853858
);
854859

855860
// Calculate slope angle

0 commit comments

Comments
 (0)