Game Development Community

Mounted object collision

by Justin Morris · in Torque Game Engine · 12/31/2004 (11:22 pm) · 7 replies

Hello, i know there is collision for mounted objects (like when the weapon moves back when you face a wall really close) but i can not find this code...

i think it would be neat to play with this code for objects mounted to the player, for instance, lets say a player is holding a health kit object in his hand, and runs into some one causing the kit to touch them, then in this code i need to find, i could find the object type, and heal the target some... or in one hand you could have a gun, and in the other hand be holding a spear, that way you can ram your spear into a player andcause damage.


this could even make for an easily implemented sword/melee system...

but i have yet to find the code for this....

would an objects onCollision code still fire if mounted to a player and it collides with another player?

#1
01/01/2005 (3:34 am)
Search for:
Quote:
// See if we are pushed into a wall...

in player.cc

The engine uses a special node in a weapon, to do a raycasting for interfering objects and pushes the weapon back accordingly.

For sword/meele this is difficult to use (looked into it already). For RealmWars we have added another step of collision detection for mounted images. This gives much better results.

-- Markus
#2
01/04/2005 (12:39 am)
Markus: Can you please tell me what you have done (for Realmwars)?
#3
01/04/2005 (3:08 am)
Don't have the code at hand, so here is just a brief concept, of how it works.

- Every shapeImage has a tsShapeInstance member, that represents the rendered mesh.
- tsShapeInstance has a castRay() implementation that allows to detect collisions with this mesh.
- The ShapeBase or Player class is extended, to expose a "rayCastWitMountedImage()" function to scripts (ConsoleMethod).
- This function does a lookup of the image mounted to a slot and exectues a rayCast on the tsShapeInstance of the image.
- In script code we do broad-phase collision detection by checking, if something enters the radius of the player or shapebase in question (RadiusSearch).
- If this is the case, we do a narrow-phase collision by doing this new raycast with the mounted images of the object in question.
- If this leads to a collision, the collision info gives us the exact collision normal and collision location on the objects mounted image.

This requires, that the dts of the mounted image is exported with proper collision info. E.g. collision mesh.

-- Markus
#4
01/04/2005 (3:17 am)
Thanx... Sounds like alot of work... I'm also busy extending the Melee Resource ripped from Realm Wars. But hopefully I'll get away with an easier way... The thing is to know where to draw the line... I don't even know if i'll have to use collision. At the moment the defender needs to block the Attackers hit by using 'block' + the same directional keys. So far things has gone smoothly... :)
#5
01/04/2005 (3:20 am)
Sounds cool.

BTW: We will have shield blocking in the next RealWars build ;)
#6
01/04/2005 (4:14 am)
RealWars Build? I desperately hope this is a typo.
#7
01/04/2005 (4:16 am)
LOL.

Sure it is.....