Game Development Community

Dynamic_cast to ShapeBase

by Edward Yee · in Torque Game Engine · 07/24/2008 (12:52 pm) · 2 replies

Hi, I'm currently trying to implement Object Selection code for TGEA 1.7. I'm running into a problem when searching for an object in Sim::findObject I'm passing in the SimObjectId and a ShapeBase *. The problem occurs within findObject when it attempts the dynamic_cast(SimObject *). It seems like it is finding the correct object, but when doing the cast back to a ShapeBase it fails and returns a null ptr.

#1
07/24/2008 (12:55 pm)
Are you sure the object is derived from ShapeBase and not ShapeBaseData or another class? dynamic_cast will return null if the object types do not match. You could try switching it to static_cast to see what happens.
#2
07/29/2008 (11:34 am)
I solved my problem, the code was working perfectly fine. The object I was trying to select was TSStatic and not Shape Base. Thanks.