Game Development Community

Colliding in middle of player

by Derk Adams · in Torque Game Engine · 06/17/2009 (1:30 pm) · 1 replies

Greetings,

I have a somewhat strange setup. I have an object(a dts building) that is a square. The walls are not collide-able (i.e. no mesh, can walk through walls), but the top is (i.e. stand on roof). The problem is that if the player is large such that the roof collision plane goes through the middle of the player's bounding box, the player gets stuck.

I would like the collision to only work when the player is on top of it, not intersected by it.

Any suggestions?

Thanks.

#1
06/23/2009 (2:38 pm)
Ok, I was able to make what I wanted. What I ended up making was the trigger box collidable, but only if it was under the player.

In player.cc

I added the trigger object to the collision mask:
static U32 sCollisionMoveMask = (TerrainObjectType      | InteriorObjectType   |
                                 WaterObjectType        | PlayerObjectType     |
                                 StaticShapeObjectType  | VehicleObjectType    |
								 TriggerObjectType |
                                 PhysicalZoneObjectType | StaticTSObjectType);

In Player::updatePos I added a check for the trigger object:
if (pConvex->getObject()->getTypeMask() & PhysicalZoneObjectType) {
                  pConvex->getPolyList(&sPhysZonePolyList);
//Begin Add
				} else if (pConvex->getObject()->getTypeMask() & TriggerObjectType) {
					if (pConvex->getObject()->getWorldBox().max.z <= start.z) {
						pConvex->getPolyList(&sExtrudedPolyList);
					}
//End Add
				} else {
                  pConvex->getPolyList(&sExtrudedPolyList);
				}

Then I made sure that the player could see it as a contact in Player::findContact:
if (objectMask & TriggerObjectType)
      {
         Trigger* pTrigger = static_cast<Trigger*>(pConvex->getObject());
         pTrigger->potentialEnterObject(this);
//Begin Add
		 if (pos.z >= pConvex->getBoundingBox().max.z) {
			if (plistBox.isOverlapped(pConvex->getBoundingBox()))
				pConvex->getPolyList(&polyList);
		 }
//End Add
	  }

So now my problem is that the player doesn't "rest" on the trigger box, but jitters. I have narrowed it down to the client not seeing the trigger box.

So... how do I make the trigger object ghosted on the client (since it looks like the code already does ghost it)?

Thanks.