Game Development Community

Item Collision question

by Adam Beaumont · in Torque Game Engine · 01/03/2005 (6:10 am) · 5 replies

I wanted to add something into the project that I'm working on that is a generic object that when a players vehicle collides with it an 'action' is performed (defined in script). It also must have a mesh.

I thought the easiest thing to do would be to just copy the item code and start from there. This sort of works, but the problem I'm having is with collision - it seems that item collision is done via world boxes using the findObjects fn, which all seemed to be aligned the same way. So if you rotate an object then the world box gets bigger to accomodate it but doesn't rotate with it (if you see what i mean).

This leads to quite innaccurate collisions - vehicles get near to my action objects and then trigger the event without ever actually hitting the mesh.

Question - can I change this collision behaviour or should I be starting from a different base class - anyone encountered this before ?

#1
01/04/2005 (12:01 am)
Have you tried changing the collision mesh of the item?
#2
01/04/2005 (9:19 am)
I don't think its that - as far as I can tell the collision between vehicles and gate type objects is done in a world box overlapping stylee - i.e. you get the world box for the vehicle then compare it against all other world boxes of a certain type and if they overlap then you have a collision - the collision meshes don't come into it.

(Both meshes have collision volumes that I think are ok)

Maybe I will need to rewrite some of that collsion code to check a bit more thoroughly if one of my new objects is intersected with...
#3
01/11/2005 (8:41 am)
The vehicles will do collision against the convex hulls of the objects (they have to, as they can ram into them), why not add a callback in that code somewhere?
#4
01/17/2005 (3:03 am)
Cos this thing is derived from an item vehicles only colliide with it as a special case in the 'collide with trigger code' i think (am actually away from pc in Hong Kong at the moment so can't check directly!).

Maybe if I add the type flag into the list of things that vehicles can ram into then that migh work.... Will investigate when I get back - thanks Ben
#5
02/02/2005 (5:32 am)
Just fyi if you happen to be browsing this thread in the future - here's what I ended up doing.

I tried making vehicles 'collide' with my trigger objects on a mesh to mesh basis by changing the collision flag of my vehicle but that started activating some of the physics code (making vehicles bounce off the objects) which I didn't necessarily want.

So I modified the trigger code such that when the vehicle collides with my objects world box I then start doing an additional check (like in the trigger code where it potentially checks if an object is a valid trigger event). In this check I basically compare distances between centers of objects and if they are close enough I then trigger my objects script action event.

It's not really a great solution but it works for the problem I had (which was trigger like objects with visibile meshes that would trigger script actions)

I may extend the code and add back in the vehicle collision so that designers can have two flavours of trigger object - one that vehicles pass through and one that they bump off of...