Hi all,
I've been struggling with this, if only because I don't know the correct terminology.
In my game I have a grapple gun which shoots rope and attaches itself to objects. Currently, it will attach to ANY object, but I'm trying to get it to only attach to objects which are derived from CGrappleObject.
Here's an example:
class CGrapplePoint
{
public:
bool IsGrappled;
};
class CHealthPack : public CGeometry, CPickup, CGrapplePoint
{
public:
//Health pack related stuffs
};
Before shooting out a rope and attaching, I raycast ahead and see what to attach to. The raycast funstion returns a CGeometry* pointer, and I want to test to see if this object is also a CGrapplePoint object.
I've tried the following:
if(dynamic_cast<CGrapplePoint*>(Raycastdata.Geometry)) ...
This always returns 0.
And:
if(static_cast<CGrapplePoint*>(Raycastdata.Geometry)) ...
This gives me the compiler error:
error C2440: 'static_cast' : cannot convert from 'sym::CGeometry *' to 'CGrapplePoint *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Which is pretty obvious, because CGrapplePoint has no relation to CGeometry.
What I DON'T want to do is have CGrapplePoint derive from CGeometry, which is probably what's making things complicated for me.
I'm out of ideas for what to Google for. Any help appreciated.