Game Development Community

CollisionBoxShape CastRay Problem

by Tony Pitman · in Torque X 3D · 12/04/2009 (1:27 am) · 2 replies

I have created a T3DBox in order to use CastRay to do some collision detection. I am using Torque X 3D Pro 3.1.4. I am having a problem.

If I create a Sphere instead and use the CollisionSphereShape as input for the CollisionBody.AddCollisionShape call the collision happens as I would expect. I am able to change the Radius and control how close to the center of the object the collision registers when I call RigidManager.CollisionBody.CollisionScene.CastRay function.

When I try to use a CollisionBoxShape (because it matches the shape I want better) then it doesn't matter what size I make the box using boxShape.Size = new Vector3 .... the collision always happens way outside of where I would expect it.

The math inside of the CastRay methods is over my head, so I can't figure it out even though I stepped into it debugging.

Please help....

#1
12/04/2009 (1:51 am)
Follow Up: I turned on RenderCollisionBounds on the collision shape and the bounds appear to be where I want them, but I am still getting collision hits on CastRay way outside of the bounds of the shape.

To be a little more specific by CollisionBoxShape size is 0.1f, 0.1f, 0.06f and I am getting hits when my site is pointing more than 10.0f distance away from the center of the shape.

I also have a CollisionSphereShape object associated with this model as well. It works just fine. The sphere is the head and the box is the body. I get hits on the sphere exactly where I want them, but the box I get hits way outside of its bounds.
#2
02/14/2010 (8:44 pm)
Only just found this. I'll link my thread here too as it sounds the same.

http://www.torquepowered.com/community/forums/viewthread/109179