Game Development Community

Problems changing collision shape size, any ideas?

by chris123 · in Torque X 3D · 08/15/2009 (7:50 am) · 2 replies

Since the dynamic models in TorqueX don't support collision meshes the coder needs to specify a collection of collision spheres and / or collision boxes to detect collisions. I'm doing an FPS and trying to define the collision shapes for the targets but no matter what I do, the collision shape is much larger than it should be. Since TorqueX doesn't support rendering collision meshes either I create a cuboid with the same dimensions as the collision box. The cuboid is rendered with the correct dimensions but the ray cast still collides with a collision box which is much larger than this. So despite being initialised to the same dimensions, it looks like the collision box shape is much larger than the rendered cuboid.

Does anyone have any thoughts on what could be going wrong? does model scaling use different dimensions to collision shape scaling?




#1
08/29/2009 (7:48 pm)
Torque X can render collision meshes, set the following property to true for your object's RigidComponent:

<RenderCollisionBounds>true</RenderCollisionBounds>

In case this causes a crash, you can add the following to the LightingMaterial() constructor method in the LightingMaterial.cs file.

_positions = new Vector3[_maxLights];
            _colors = new Vector3[_maxLights];
            _ambients = new Vector3[_maxLights];
            _attenuations = new Vector2[_maxLights];

This will properly initialize the lighting. This fix has been added included into the next Torque X release, 3.1.4

John K.
www.envygames.com
#2
08/30/2009 (3:42 pm)
Another short fix that I used was changing the physics objects to render collision meshes as simple materials and not lightning materials.

Edit: And if you are using Collision Cubes I was running into many issues with the collision cubes and terrain meshes, and could only get a good degree of collision detection on terrains with the spheres.