Game Development Community

Collision Problem

by Demolishun · in Torque Game Engine · 09/30/2006 (9:23 pm) · 3 replies

Here is my update loop for my collision in my object based upon gamebase:
void ObjectBase::updatePhysics()
{
   F32 collisionTol = 0.1; // Temporary

   // Update collision information
   MatrixF mat,cmat;
   mConvex.transform = &mat;
   //mRigid.getTransform(&mat); // look into this
   objectState.rotation.setMatrix(&mat);
   mat.setColumn(3,objectState.position);
   cmat = mConvex.getTransform();
   
   mCollisionList.count = 0;
   CollisionState *state = mConvex.findClosestState(cmat, getScale(), collisionTol);
   if (state && state->dist <= collisionTol) {
      //resolveDisplacement(ns,state,dt);
      mConvex.getCollisionInfo(cmat, getScale(), &mCollisionList, collisionTol);
   }
   if(mCollisionList.count)
      Con::printf("mCollisionList.count: %d",mCollisionList.count);
}

The problem is I have my object in the terrain block, but I am not getting any collisions. "state" always is NULL after the call to findClosestState. Do I need to provide a mask tosomewhere to say that this what this object is collidable against? What about terrain? Right now the object does not move, but I expected to see collisions.

This function is currently called from ProcessTick in a child class of this one. I did check and the objectState structure does reflect where the object is supposed to be in world space.

About the author

I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67


#1
10/01/2006 (11:55 am)
Doh!

I needed this before the call to the updatePhysics call:
updateWorkingCollisionSet(getCollisionMask());

Now I am colliding, now I am colliding!
#2
10/01/2006 (1:07 pm)
I figured you had that in processTick so did not bother to suggest it :) Glad you got it working!
#3
10/01/2006 (3:23 pm)
Hey I have another question related to this. Why is it when I move my object in the editor and hit F11 twice to go out and back into the editor the object is where it was to start. But when I hit apply after changing the position manually in the position entry input dialog section that it stays? I know I am missing something, but I have been searching through the editor to see where dragging the object changes its position to, but so far cannot find it.

Thanks,
Frank