How to use the collision shape in a CSGCombiner node?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bborncr

According to the docs the use_collision flag “Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body.”

If it acts like a static body shouldn’t there be a mouse_entered() signal in the node?

How is the collision shape accessed?

I’m trying to create a selectable object using CSGShapes.

:bust_in_silhouette: Reply From: wombatstampede

You could use raycasting from the camera to get the clicked CSGShape.

Look in this Q&A for inspiration (this probably is for Godot 2.x but should also be usable in Godot 3.x):

You’ll see that they use _fixed_process (now called _physics_process) to cast out rays to the mouse position. camera.project_ray_origin(mouse_pos) does the conversion of a mouse-position to a 3d position to be used in a raycast.

You’d probably have to set a variable (mouse_pos) in the camera script which saves the last mouse position delivered to _input(event)

So raycasting detects the static body in CSGShape. Tested and it works!


bborncr | 2019-04-15 16:05