Game Development Community

Strange thing happening with collisions of AI with a non-square bounding box

by Richard Marrevee · in Torque 3D Professional · 05/24/2012 (10:48 am) · 10 replies

There is a strange thing happening when colliding with AI's that don't have a square bounding box (height doesn't matter). When AI's rotate the collision box doesn't rotate at all. See the images below where I set the player collisions to visible.

games.marrevee.com/images/rat_collision1.jpg
Image 1: AI aligned with y-axis

games.marrevee.com/images/rat_collision2.jpg
Image 2: AI rotated but the collsion box stays aligned with y-axis.


Video showing the problem

My question is: is this caused by the setup rat-model or is there some kind of bug? When the rat is rotated it is possible to walk into the rat until the players bounding box collides with the rat-box.

Help is very much appreciated.

Edit: I'm using T3D 1.1 with 1.2 bug-fix applied.

Edit2: Added a vid.

Thanks

About the author

Started programming in 1984 on an Oric, when time progressed switched to MSX, Amiga and finally the Windows PC with T3D. Now developing an epic fantasy game: The Master's Eye. Creator of the DoorClass pack and VolumetricFog pack @ richardsgamestudio.com


#1
05/24/2012 (11:06 am)
I have no knowledge of this but I can come with some guessing.
How do you rotate the rat ?
Maybe the player is caching it and the box for some reason doesnt update .
Cant come with any other case this would happen unless the rotation is an animation.
#2
05/24/2012 (11:54 am)
@Lukas:
It isn't an animation. The Ai targets with setaimlocation(...)

Remembered that i'v read about an issue with setaimlocation, but couldn't find it.

Also some more testing using setTransform shows the same problem.
Tried it with a "square" AI and walked around it. What happens is that the AI rotates in it's box which stays in the same position and orientation.
#4
05/24/2012 (1:17 pm)
Found this thread. The problem is described in the thread Guy Allard posted, but i believe the beforementioned thread has a possible solution for it.
Quote:What I need, is to create a box that is the same as the MObjBox, except it's rotated, and scaled. When I think about this, I think that this should just be the mWorldBox, but I think I already tried this and didn't get it to work correctly. I will try this again.
Edit:
This thread aswell describes the issue and points to collisionMatrix and says you can fix it there, however there is some issues related to this and you would probably need to spend some time fixing it.
Although i find it hard to believe it is build this way. From what i've read it is for increasing the performance, it just seems like a bad solution in many cases.
#5
05/24/2012 (1:26 pm)
Thanks guys, it seems that I have to dig deep to get this resolved.
#6
05/25/2012 (12:57 pm)
Richard, col has to be square on skinned meshes (unfortunately). ColBox is aligned with global and not local coordinates (but you've probably worked that one out by now) ;)
#7
05/26/2012 (4:08 am)
Quote:col has to be square on skinned meshes

That's sad.:(

If the reason it is done this way is increasing performance, I can understand it, although it seems a bit strange, that the objects world box is updated every time you perform a rotation (you can find it out yourself using yourObject.getWorldBox(); in script), but the col isn't.

That said, I still need a solution to this problem (cause I have some models which are pretty rectangular), so I will chew on this a little bit more.
#8
05/26/2012 (6:37 am)
@Richard if you manage to figure something please post it as i find it troubling aswell.. The amount og limitations this put to model meshes.. It's a very unpleasant thought!
#9
05/26/2012 (1:52 pm)
There is a quick solution to this problem, unfortunately it comes with a cost in fps.

In any case this is the solution:

In player.h change
OrthoBoxConvex mConvex;

in

BoxConvex mConvex;

And in Player.cpp change in Player::buildConvex(const Box3F& box, Convex* convex)

// Create a new convex.
   BoxConvex* cp = OrthoBoxConvex;

into

// Create a new convex.
   BoxConvex* cp = new BoxConvex;

As mentioned this comes with a cost in framerate, I'm not entirely sure how much, therefor the best way seems to create a player-like class which has this changes and use this for non square models and use the OrthoBoxConvex in the Player class.

#10
05/29/2012 (3:04 pm)
@Richard
Know it's a little late, but played with this today and i got the collision box to work on a rectangled object.
But the thing is it only updates when the player moves around a bit, atleast it works for me.
And it was a static mesh not an ai might have something to do with it.