I'm trying to find a way I can write a script that detects a collision directly from StaticBody3D or CollisionShape3D. Currently I'm using CharacterBody3D physics update to check for collision against a stage exit portal.
private void CheckForStageExit() {
for (int index = 0; index < GetSlideCollisionCount(); index++) {
// We get one of the collisions with the player.
KinematicCollision3D collision = GetSlideCollision(index);
// If the collision is with a mob.
if (collision.GetCollider() is StaticBody3D) {
StaticBody3D temp = (StaticBody3D)collision.GetCollider();
if (temp.Name == "StageExit") {
GD.Print("StageExit");
}
}
}
}
This method does work but it will become cumbersome with the more stages I add to the game. I'd like a way to add a script directly to my static body that can raise an event when the player body enters, like with rigid body enter event. I'm not sure if this is even possible if it I'd like to know how it's done.