Game Development Community

Raycast inside a building

by Howard Dortch · in Torque 3D Professional · 01/18/2015 (7:19 am) · 3 replies

I have a static shape building with collisions. I can cast a ray and select objects in the building (all static shapes) but cant target the building itself. Tried all the mask bits and never hits. Want to get the distance from a wall so players can't set items inside the wall. Any ideas ?

#1
01/18/2015 (7:57 am)
I think you may need to use TSStatic for your buildings if you want that kind of functionality. Container raycasts against a StaticShape don't use the geometry, but use the bounds/convex hull.

Alternatively, subclass StaticShape and re-write the castRay function in the new class to use castRayRendered.
#2
01/18/2015 (6:59 pm)
You could probably add a bunch of (convex) collision meshes that closely match the form of your building shape. IIRC ShapeBase does handle lots of collision meshes correctly.
#3
01/19/2015 (11:01 am)
Thanks for the reply.
@Guy changing to a TSStatic would be a major code redo. I create the buildings on the fly from a database passing datablock info. I thought raycast hit the collision mesh. If I made the walls all separate collision meshes do you see that working?

@Daniel I grouped all the collisions into a single collision-1 mesh so because it would be concave might be a issue?

I suppose I could do a InitContainerRadiusSearch with a small radius at eyepoint. Not sure why that works in the building vs a raycast.