Game Development Community

ContainerRayCast bug?

by Howard Dortch · in Torque Game Engine · 07/06/2006 (9:50 am) · 5 replies

I have an object I want to interact with. I walk up to the object hit the U key to use it and the interact code does a routine as such:

%searchMasks = $TypeMasks::StaticShapeObjectType;

%scanTarg = ContainerRayCast (%startPoint, %endPoint, %searchMasks, %player);

all is well, the target gets selected.

I go out of the room and around to the other side of the wall ( this is in a building ) to a position opposite the object and hit the U key viola, I can access the object from the other side of the wall.

So the interior wall does NOT exist ? ContainerRayCast ignores interior walls ?

#1
07/06/2006 (9:59 am)
... You're using a typemask of StaticShapeObjectType, so the raycast is only checking for that kind of data. Try changing it to InteriorObjectType.
#2
07/06/2006 (12:02 pm)
You missed the point, shouldn't raycast return 0 if the object is obscured by another?
#3
07/06/2006 (12:27 pm)
Yes Howard it should, if that object's typemask is in the collision argument of containerRayCast. So if you want it to collide with the interior, you'll have to include that in the collision argument.

I'm pretty sure this is the case but I could be wrong, haven't touched rayCasts in a few months.
#4
07/06/2006 (12:37 pm)
Raycast ignore any types not in their mask, so it's passing right through the interior. That's how it's supposed to work. The only time a raycast returns 0, is if it hit nothing of the type it's checking for. If you want something to be able to obscure it, you need to check for what can obscure it as well.

So you would change your search to:
%searchMasks = $TypeMasks::StaticShapeObjectType | $TypeMasks::InteriorObjectType;
And then you'll need to add a check against something like:
if(%scanTarg.getType() & $TypeMasks::StaticShapeObjectType)
To make sure you only try to act on a valid object.
#5
07/06/2006 (1:35 pm)
I changed the code to do this so it would work only I used %scantarg.getClassName() to test it. Other ray/collision routines I did for DX just passed back a 0 if the first object was not the target, seemed more efficient to do it in C++. thanks for the reply guys...