containerRayCast troubles with new object type
by Jacob Dankovchik · in Torque 3D Professional · 02/22/2014 (9:11 am) · 10 replies
So for this game I'm working on, I basically needed to make a new object type. I decided to copy the tile object since it had some behaviors I also needed and renamed it to Tile Object. The trouble I'm having though is it doesn't seem to be recognized by a container ray cast.
Here is the script code in question:
Checked in the console, TileObjectType is a proper console variable assigned a value as it should be. It also collides and behaves normally but just refuses to be seen by the ray cast. I know the ray cast works as it catches other things, just not these tile objects. Is there perhaps a certain property about items themselves that may be causing this? Some help would be very appreciated as I need to get this solved before I can really progress any further. :(
Here is the script code in question:
%player = "shooter";
%pos = %player.getPosition();
%x = getWord(%pos, 0);
%y = getWord(%pos, 1);
%z = getWord(%pos, 2);
%z += 2;
%start = %x SPC 0 SPC %z;
%ray = "0 0 1";
%ray = VectorScale(%ray, 200);
%end = VectorAdd(%pos, %ray);
%searchMasks = $TypeMasks::TileObjectType;
%scanTarg = ContainerRayCast( %start, %end, %searchMasks);Checked in the console, TileObjectType is a proper console variable assigned a value as it should be. It also collides and behaves normally but just refuses to be seen by the ray cast. I know the ray cast works as it catches other things, just not these tile objects. Is there perhaps a certain property about items themselves that may be causing this? Some help would be very appreciated as I need to get this solved before I can really progress any further. :(
About the author
#2
02/22/2014 (9:55 am)
Yup. That's there, I went through line-by-line compared to a few other object types now to make sure it's establishing in exactly the same way.
#3
02/22/2014 (10:07 am)
you did expose $TypeMasks::TileObjectType to script right? The engine won't automatically do it.
#4
02/22/2014 (10:26 am)
Yup. Like I mentioned in the original post, I checked in console and it is exposed to script and assigned a value by the engine, as it should be like the other type masks.
#5
Just another basic question so we can roll it out: do these tile objects have a collision mesh on them?
02/22/2014 (10:31 am)
Really odd as I have exposed new types and they've worked fine.Just another basic question so we can roll it out: do these tile objects have a collision mesh on them?
#6
02/22/2014 (10:34 am)
I don't believe so, at the moment. Collision itself works just fine, but would the lack of a mesh be a possible culprit? At the moment I'm just using a stock cube mesh that was packed with T3D for just basic testing. Forgot to bother with collision mesh. I may have to try that once I get a chance.
#7
Thanks for the line of thought! Wasted a ton of time already trying to get it to work. :( But back to progress!
02/22/2014 (10:55 am)
Well I'll be damned, that was the problem. I figured native bounding box collision would've been sufficient, since it was able to collide with objects without a collision mesh. Guess you need the mesh for ray casts though. Thanks for the line of thought! Wasted a ton of time already trying to get it to work. :( But back to progress!
#8
Or, you could rework the container system to check bounding boxes.
02/22/2014 (11:01 am)
Heh, sorry I assumed from the beginning you were using a mesh. Yeah, its silly like that. If you are using physX and expose the physX raycasting system you might be able to get away with just bounding boxes, but for now you'll need a collision mesh with default T3D.Or, you could rework the container system to check bounding boxes.
#9
Which hopefully I'll be making a blog about this very soon. :) Excited for this project. I'm using T3D for essentially a 2D game. My logic is that I'll be able to do a bit more visually fun things, hoping that pays off in the end.
02/22/2014 (11:04 am)
Na, this will work just fine I think. I wanted proper collision in place, just didn't bother yet because I didn't need at this time. Just using massive amounts of placeholder work while I build the code.Which hopefully I'll be making a blog about this very soon. :) Excited for this project. I'm using T3D for essentially a 2D game. My logic is that I'll be able to do a bit more visually fun things, hoping that pays off in the end.
#10
02/22/2014 (1:42 pm)
good luck on your project, I'm making a game in Torque3D myself but won't go into detail at this time about it. Happy raycasting =P
Torque Owner Richard Ranft
Roostertail Games
TileObject::TileObject() { mTypeMask |= TileObjectType; ....