Collision Checking?
by Matt "Mr. Pig" Razza · in Torque Game Engine · 12/20/2005 (12:56 pm) · 6 replies
I would like to code a function into the engine (not scripted) to check for collisions. I plan on sending the function the objects starting point and it's ending point and I would like it to return true/false if it finds a collision or not. I know C++ but would like to know what is required to make the function able to be used in script as well as how to check on collisions. It will only 5 points on the "grid" it will be moving so just checking each point for a collision won't take much CPU.
Thanks,
Pig
Thanks,
Pig
About the author
#2
12/20/2005 (1:15 pm)
Will do, rayCast. Thanks, I forgot the name. I used it before when messing with Projectile.cc
#3
12/20/2005 (1:34 pm)
I found many castRay/rayCast references. I will be playing with some of them, but I was wondering if there is any way for checking if there is another object at a location (one point on the 3D grid). If not I could port my current code to support rayCasts.
#4
12/20/2005 (1:40 pm)
If it's a true "3d" grid you could use a container radius search at the point you want to check. If it's a 2-d grid over 3d space you can just use a containerRaycast. See the radiusDamage.cs file to see how to do the container radius search (it's a set of script functions), and containerRaycast is a script function on it's own.
#5
To check against specific object types, set the typeMask to suit your needs. You can check fro players, vehicles, terrain, interiors... basically any object typ in the engine.
When you define you typemask, only objects that match the type(s) specified are returned. All others are ignored.
[edit]
If you are wanting to search an area around the player, or otherwise don't have your exact ending location or vector, the containerRadius search mentioned above would be ideal.
12/20/2005 (1:41 pm)
This is from memory, so forgive me if I'm off, but it seems that there IS a castray() function that accepts a start point and an end point (it would seem the vector would be implicit, but don't quote me) that should do what you need.To check against specific object types, set the typeMask to suit your needs. You can check fro players, vehicles, terrain, interiors... basically any object typ in the engine.
When you define you typemask, only objects that match the type(s) specified are returned. All others are ignored.
[edit]
If you are wanting to search an area around the player, or otherwise don't have your exact ending location or vector, the containerRadius search mentioned above would be ideal.
#6
12/20/2005 (8:28 pm)
Yes, there is, in script it's containerCastRay in c++ it's castRay.
Torque Owner Kirby Webber
I'd suggest searching the site and the documentation before trying to code up a custom solution. Odds are, it's already there.