Is there a way to generate a collision shape around a path?
Asked Answered
S

4

0

Hi, I'm making a tower defense game and I was trying to figure out a way to form an Area3D around a Path3d that I use for enemies to prevent towers from being placed in the enemies' path. So far the only thing I've found is this video

but it only uses CSG Polygons. Unless there is a way to copy a collision polygon's shape I don't know how to form a collision shape for an area around a path. Any ideas?

Sagittal answered 3/1 at 21:27 Comment(0)
B
0

Sagittal Unless there is a way to copy a collision polygon's shape

You can do that. For example, a CollisionShape3D's shape property is a Shape3D. If the Shape3D is a ConvexPolygonShape3D, then its points property is a PackedVector3Array containing the polygon vertices.

Blackbird answered 3/1 at 22:33 Comment(0)
T
0

CSGMesh3D has a 'Use Collision' (doc) property; is this as simple as setting it to true? And if not, get_meshes() returns the Transform and Mesh for the shape, where the mesh can create a collision shape via create_trimesh_shape (doc).

Turnout answered 4/1 at 16:23 Comment(0)
S
0

Turnout that works, but the only issue is that it is registered as a body and not as an area, I'd rather have it be considered an area for multiple reasons.

Sagittal answered 6/1 at 19:13 Comment(0)
T
0

Understandable. Given the engine can create the shape, and a reference to the mesh, is it possible to copy/assign the shape to an area and later disable the body?

The use of layers/masks to remove interactions due to collisions might also help.

Turnout answered 7/1 at 10:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.