Hi, and again I may be to stupid to get the easiest stuff right, so sry beforehand
I tried to recreate your 3rd person character controller from the samples and did the basic setup with a world collider, a character controller and a floor. The floor cube is at 0,0,0, the world collider is 20,20,20 in scale and IsTrigger set to true. The character controller is on the IgnoreRaycast layer, startposition on 0,2,0, has a rigidbody with useGravity is true attached and the AutoReset basically copied from the samples. But when I start the scene, my cube won’t move down by gravity, but instead the onTriggerExit event is fired continuously. Oo
import { Behaviour, Collider, GameObject, Rigidbody, serializeable } from "@needle-tools/engine";
import { Vector3 } from "three";
export class AutoReset extends Behaviour {
@serializeable(Collider)
worldCollider?: Collider;
@serializeable(Vector3)
startPosition?: Vector3;
start() {
if (!this.worldCollider) console.warn("Missing collider to reset", this);
console.log("start position", this.startPosition);
}
onTriggerExit(col) {
if (col === this.worldCollider) {
console.log("reached world collider");
this.resetToStart();
}
}
resetToStart() {
if (!this.startPosition) return;
const rb = GameObject.getComponent(this.gameObject, Rigidbody);
//this.setWorldRotation(0, 0, 0, true);
//this.setWorldPosition(this.startPosition.x, this.startPosition.y, this.startPosition.z);
rb?.teleport(this.startPosition);
}
}
I investigated further and created a repo to check this behavior → https://github.com/FireDragonGameStudio/NeedleCharacterControllerCheck As it seems atm it is related to the ChracterController and it’s interaction with the trigger box collider. The project has a scene called “TriggerTest”, where everything is setup like the 3D character controller scene from the samples.
When working with a normal BoxCollider, everything works as it should. Box falls through the WorldBoundsTrigger and gives console logs → 1 for entering, multiple while staying and 1 for exiting the trigger collider.
But when I enable the box with the CharacterController instead, which is imho set up correctly, it only works (most of the time) in the first try. After reloading the page, all the Trigger events are executed multiple times.
That makes sense! But wouldn’t that mean, that the capsule collider in Rapier would generally behave like this, when being used in combination with a sensor collider?