Game Development Community

Static collision problems

by luggage · in Torque X 2D · 06/14/2008 (8:56 pm) · 5 replies

Hello

When I add my own .dts file to the FPSDemo it all works perfectly when the scale is 1,1,1. If I change the scale of the object to 4,4,4 the collision seems out. It's larger than the visual model and not as high. Is there something else I'm supposed to do?

Thanks

Scott

#1
06/15/2008 (2:16 pm)
Did you change both the collision body size and the shape size? They are seperate components, I'm not sure if they'd update each other automatically. I wonder if John K's editor includes the ability to add collision bodys and size them in the editor, that would be a great feature.

Will
#2
06/15/2008 (3:43 pm)
I don't seem to have a collision body size. I have the following...

<StaticGeometry type="GarageGames.Torque.Core.TorqueObject">
      <Components>
        <RenderComponent type="GarageGames.Torque.T3D.T3DStaticTSRenderComponent">
             <ShapeName>data/shapes/structures/GeneralStore.dts</ShapeName>
        </RenderComponent>
        <StaticGeometryComponent type="GarageGames.Torque.T3D.T3DStaticGeometryComponent">
	   <Position>
		<X>315.18</X>
		<Y>-180.418</Y>
		<Z>244.913</Z>
	   </Position>
           <Rotation>
                <X>0</X>
                <Y>0</Y>
                <Z>-0.9903263</Z>
                <W>-0.1387582</W>
           </Rotation>
           <Scale>
                <X>4</X>
                <Y>4</Y>
                <Z>4</Z>
            </Scale>
        </StaticGeometryComponent>
        <RigidComponent type="GarageGames.Torque.T3D.T3DRigidComponent">
             <RigidManager nameRef="RigidManager" />
             <Immovable>true</Immovable>
        </RigidComponent>
      </Components>
</StaticGeometry>

If the scale is 1, 1, 1 everything is fine. If I set it to 4,4,4 the model is bigger but the collision box is wrong. The collision is definately scaled but it's too wide and not tall enough - something happens to it but I can't tell what. Is there a way to render the collision box?
#3
06/15/2008 (7:52 pm)
I have no idea how that rigid component is working, it doesnt seem to have a collision shape at all, here are some examples of what i'm talking about, taken from the desertPhysics.txscene file

First the sphere

<RigidComponent type="GarageGames.Torque.T3D.T3DRigidComponent">
          <RenderCollisionBounds>false</RenderCollisionBounds>
          <CollisionShapes>
            <CollisionShape>
              <Shape type="GarageGames.Torque.T3D.RigidCollision.CollisionSphereShape">
                <Radius>0.25</Radius>
                <Center>
                  <X>0.0</X>
                  <Y>0.0</Y>
                  <Z>0.0</Z>
                </Center>
              </Shape>
            </CollisionShape>
          </CollisionShapes>
          <GravityScale>1.5</GravityScale>
          <RotationScale>1.0</RotationScale>
          <RigidManager nameRef="RigidManager" />
          <RigidMaterial type="GarageGames.Torque.T3D.RigidCollision.RigidMaterial">
            <Restitution>0.2</Restitution>
            <KineticFriction>1.8</KineticFriction>
            <StaticFriction>1.4</StaticFriction>
          </RigidMaterial>
        </RigidComponent>


also the box
<RigidComponent type="GarageGames.Torque.T3D.T3DRigidComponent">
          <RenderCollisionBounds>false</RenderCollisionBounds>
          <ResolveCollisions>true</ResolveCollisions>
          <Mass>2.5</Mass>
          <CollisionShapes>
            <CollisionShape>
              <Shape type="GarageGames.Torque.T3D.RigidCollision.CollisionBoxShape">
                <Size>
                  <X>4.0</X>
                  <Y>4.0</Y>
                  <Z>4.0</Z>
                </Size>
                <Center>
                  <X>0.0</X>
                  <Y>0.0</Y>
                  <Z>0.0</Z>
                </Center>
              </Shape>
            </CollisionShape>
          </CollisionShapes>
          <RotationScale>1.0</RotationScale>
          <GravityScale>1.5</GravityScale>
          <RigidManager nameRef="RigidManager" />
          <RigidMaterial type="GarageGames.Torque.T3D.RigidCollision.RigidMaterial">
            <Restitution>0.1</Restitution>
            <KineticFriction>0.9</KineticFriction>
            <StaticFriction>0.7</StaticFriction>
          </RigidMaterial>
        </RigidComponent>


You can also set these manually in code, it might be easier then writing to a txscene file
#4
06/15/2008 (8:07 pm)
I used the same stuff as the buildings in the desertlevel.txscene. I'm using the FPSDemo as a base.
#5
11/06/2009 (9:54 am)
Hey Luggage,

Did u ever find a fix?

Cheers,