How to detect collision for scene change in 3D?

Godot Version

4.2.2

Question

Hello,
I have been trying to make it so that when my player (CharacterBody3D with child CollisionShape3D in capsule shape) Touches a building (A StaticBody3D with children MeshInstance3D and CollisionShape3D with ConcavePolygonShape3D) the scene changes. The collision itself works- you can’t clip/walk inside of the building, but I can’t figure out what to put on the script / which entity to even put a script on to ‘listen’ for the player colliding with the building to then run the line:

get_tree().change_scene(“res://insideScene.tscn”)

Every solution I’ve found online has either been not descriptive enough or too complicated for the simple scene change I’m trying to implement, at least to start with. I have tried __on__body_entered and it just doesn’t do anything.

TLDR, my questions are:

  1. How to get the script for the objects above to recognize a player/object collision? Is there a certain function I need to use?
  2. Which object(s) do I apply the script to?
    Thank you!

You could create an Area3D and make it slightly larger than the building itself. Then, you could connect the body_entered signal to change the scene. I’d recommend adding the player to a group and checking body.is_in_group("GroupName") so random objects don’t trigger the scene change.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.