Game Development Community

Crouch does not affect collision?

by Marcus L · in Torque 3D Professional · 11/07/2009 (8:23 am) · 8 replies

Does anyone know if crouching affects the players collision, because i tried and it didn't seem like it did. I need the crouching to affect the collision so i can crawl through tight spaces (ventilation systems .etc).

If anyone haves the solution, please tell me.

#1
11/07/2009 (9:39 am)
When crouching your box will be set again.
Use crouchBoxSize in your player's datablock.
#2
11/07/2009 (12:24 pm)
I thought that boundingbox changed automatically with stance (in player.cpp).

Also crouchboxsize seems missing from stock player script.

After a quick check of player.cpp, crouchboxsize code isn't much smaller than normal boundingbox size (2.0 compared to 2.3).

I do have a slightly "bouncy" crouch_walk animation which doesn't help when trying to get under things too .... but prone works fine for getting through tight spaces.

[edit_after_a_play_around]
I'm not convinced crouchboxsize is doing anything in script. It might be better to change the values in the code.

#3
11/07/2009 (1:19 pm)
It should work.
At the bottom of updateMove() is called setPose()
If we check ahead,we'll see:

case CrouchPose:
         boxSize = mDataBlock->crouchBoxSize;

And then we see how it is applied:
// Object and World Boxes...
   mObjBox.maxExtents.x = boxSize.x * 0.5f;
   mObjBox.maxExtents.y = boxSize.y * 0.5f;
   mObjBox.maxExtents.z = boxSize.z;
   mObjBox.minExtents.x = -mObjBox.maxExtents.x;
   mObjBox.minExtents.y = -mObjBox.maxExtents.y;
   mObjBox.minExtents.z = 0.0f;

   resetWorldBox();

   // Setup the box for our convex object...
   mObjBox.getCenter(&mConvex.mCenter);
   mConvex.mSize.x = mObjBox.len_x() / 2.0f;
   mConvex.mSize.y = mObjBox.len_y() / 2.0f;
   mConvex.mSize.z = mObjBox.len_z() / 2.0f;

   // Initialize our scaled attributes as well...
   onScaleChanged();
#4
11/07/2009 (1:32 pm)
Just tried it in the editor with player selected (so that I can see the bounds) and then switch to 3rd person. The boundsbox doesn't resize when I got into crouch, does resize when I go prone.
#5
11/07/2009 (1:37 pm)
If it does not work,then it's a bug.
Actually i tested this fragment a few days ago and it works.
But i didn't use the poses and how it is intended to be used.

@Steve
try using crouchBoundingBox in the datablock
#6
11/07/2009 (1:58 pm)
roflcopter

Yeah that's the one Pic - and I so thought of trying it ... but then didn't.

I can see it in the code now, too. Reckon I just confused myself there (which does happen with alarming regularity!).
#7
11/07/2009 (3:22 pm)
Thanks, it works. Edit: I personaly think the values for the standard gideon player should be changed to:
boundingBox = "1 1 1.66";
   crouchBoundingBox = "1 1 1.45";
#8
11/18/2009 (6:24 pm)
Good to see this isn't broken, thanks guys.