Detecting collision with BetterCharacterControl

Please read this thread to know what’s happening: [SOLVED...?] CapsuleCollisionShape with collideWith() and/or alternative to collision - #15 by Dgames_Crew

If you read the thread I put in this thread, you will see that I had an issue with collision with BetterCharacterControl. I decided to make a whole new thread because I asked 2 totally different questions relating to collision.

Please use this example: BetterCharacterControl Example

I want to make it so if you touch a red block, a trigger will print in the console. I’ve done this with CharacterControl, but I just want to do it with BetterCharacterControl. Thanks! :smile:

I would use two BoundingVolumes, one that follows the player (or you can use the player’s spatial) and one for the touch zone. This way you aren’t limited to using the player’s capsule collision shape associated with the character control, you can either use the Spatial’s bounds, or define a custom sized boundingbox / boundingsphere if the overlap zone is larger than the player.

Spatial player;
Spatial redBox;
if(player.getWorldBounds().intersects(redBox.getWorldBounds();)){
     //dostuff
}
1 Like

Wait, I currently have a player model as a geometry box, will it still work or do I have to change it to a spatial?

Geometries have the method .getWorldBound() so it should work just the same

Also if there isn’t any collision at first, then you may want to use a bounding box for the player that’s slightly larger than the player, since a player would usually be able to touch something that’s a few feet away from them, and if both objects have a physics control the same size as the bounding volume’s then they can’t fully overlap.

1 Like

Alright, thanks for the help! I’ll bump if any errors occur. :smile: