Game Development Community

Can you add multiple collision and physics components to an obj?

by John Klimek · in Torque X 2D · 09/01/2007 (9:04 pm) · 4 replies

Sorry for all of the questions lately but I'm still trying to wrap my head around the component model being used for TorqueX.

Can you add multiple collision and physics components to an object?

For example, let's say you have a T2DSceneObject with a T2DStaticSpriteComponent.

Now let's say you add a T2DCollisionComponent. Does the collision component get it's collision polygon from the T2DStaticSpriteComponent?

What would happen if you added a second T2DStaticSpriteComponent and/or a second T2DCollisionComponent? Does it somehow automatically figure out collision polygons? How does it know to use the T2DStaticSpriteComponent? Suppose it was a T2DTriangleComponent instead of a T2DStaticSprite component?

I guess my main question is this: Where is the collision polygon stored? In the T2DSceneObject or in the individual components such as T2DStaticSpriteComponent?

Thanks for your help!

#1
09/02/2007 (11:13 am)
There is no T2DStaticSpriteComponent. T2DStaticSprite "is a" T2DSceneObject as it inherits from it.

The collision polygon is stored in the collision component, which belongs to a T2DSceneObject (which can be a T2DStaticSprite or T2DAnimatadcSprite). -> One sprite, (at most) one collision component.
#2
09/02/2007 (4:09 pm)
Ahh, sorry. I mis-read the SDK documentation but now I see that T2DStaticSprite is-a T2DSceneObject.

Sorry, but I have a few more questions...

1) Can a T2DSceneObject (base object) have a collision component?

2) Does the collision component create it's collision polygon based on the T2DStaticSprite polygon shape or something? I'm still confused on how (and when) the collision polygon is created and stored.

3) Can all T2DSceneObjects only have ONE collision component? What about physics? What happens if you add more than one of these type of components to a scene object?

Thanks for your help!
#3
09/03/2007 (7:24 am)
1/2) I think that sprites always have a rectangular shape. You can draw the collision polygon in TXB if your T2DSceneObject has a collision component (which it has by default). The effect of having more than one collision polygon is explained in ths API doc for "T2DCollisionComponent" -> "Members".

3) Why would you want to have multiple physics components? What do you want to achieve?
#4
09/03/2007 (8:29 am)
I think you might be barking up a very confusing tree. I'd instead consider how you could extend the current physics and collision components to suit your needs with a single instance.