Game Development Community

Interact Key example

by Howard Dortch · in Torque Game Engine · 07/19/2004 (8:29 am) · 15 replies

I put the chapter 6 tutorial "Creating an Interact Key" in my game and can't get it to work.
Seems the %scanTarg = ContainerRayCast (%startPoint, %endPoint, %searchMasks, %player);

never returns a valid %scanTarg. it's always 0.

I printed the values of my player eye start and end points and they are valid.

Any suggestions?

#1
07/19/2004 (9:14 am)
What searchMasks are you using?
#2
07/19/2004 (9:37 am)
From the tutorial

%searchMasks = $TypeMasks::ShapeBaseObjectType;
#3
07/19/2004 (9:58 am)
The only things I can suggest are the following;

Double check the Code for ContainerRayCast, as I don't see it as part of the normal Torque Code.

Make sure that your %startPoint and %endPoint are values you expect. For instance, is %endPoint infront of you where you expect it? (When I did my pick code, I had my %endPoint behind me by accecdent, it was still valid, just in wrong direction.)

Make sure the shape object you are trying to select is within the %startPoint %endPoint.
#4
07/19/2004 (10:10 am)
Morning Simon!

here is the link on what im trying to do:
http://www.garagegames.com/docs/torque/general/ch06s04.php

I got the raycast to work now, they had a spelling error

So I get a %object now but this routine can't find the interact function.


%object.getDataBlock().interact(%object,%client);
#5
07/19/2004 (10:39 am)
Interact is not a standard method

looking at the tutorial, specificaly switch.cs, they have added an interact function to Switch.

So any objects you want to interect with, you will have to add a interact function.

They kinda talk about it in the 'Scripting the switch' section of the tutorial.
#6
07/19/2004 (10:47 am)
Yeah I got no prob with that just wish the tutorials would at least work so someone could learn.

I guess I could make it an item like a gun and collide with it to get interaction.

God this is frustrating
#7
07/19/2004 (11:23 am)
Well, actually, in point of fact, if they just magically worked for you...would you have learned as much as you do when they DON'T work and then you have to dig through?
"just wish the tutorials would at least work so someone could learn." seems somewhat counter-intuitive.
#8
07/19/2004 (12:34 pm)
Well IMHO I think a tutorial should show the proper way to do something and let the user modify from there. But this is off subject. Have you got this to work David? If so could you help me understand it?
#9
07/19/2004 (1:44 pm)
...
#10
07/19/2004 (2:02 pm)
Object you want to detect need a collsiion box.
#11
07/19/2004 (2:48 pm)
@Joseph, yes thats the one except the example used a chrome lookin switch.dts. I get 0 for return on collision.

@Robert there was a zip file at the bottom I just used what they had, it was a switch.dts, I assumed it had collisions since I can run into it and collide.
#12
07/19/2004 (2:58 pm)
...
#13
07/19/2004 (3:51 pm)
Yeah I checked for errors and fixed them. I echo() all of the information to make sure the ray start and end points are valid as and they seem to be. Facing the character at +Y I get something like Point3F(20,20,100) for start and Point3F(20,30,100) for end, distance of 10. I also checked to see if the vector was (0 1 0) and it is. I tested the ray on my own engine and they are valid numbers so the only thing I can think of is the %mask is wrong or the object does not exist or has bad obj value.

here is the object:
datablock StaticShapeData(MySwitch)
{
category = "Misc";
shapeFile = "~/data/shapes/items/pieces/switch.dts";
isSwitchOn = false;
};

and here is the mask
%searchMasks = $TypeMasks::ShapeBaseObjectType ;


the switch object shows up in the world, and I can collide with it.
#14
07/19/2004 (3:59 pm)
...
#15
07/19/2004 (4:25 pm)
How bout a ak47? bullits, grenades all collide with it.

I put in other objects just to see if I can get a hit of any kind and no go.

the ContainerRayCast works in my engine because I use it in another place before you ask...

I did notice one thing in the console log
Game/server/scripts/switch.cs (0): preload failed for MySwitch: ShapeBaseData: Couldn't load shape "Game/data/shapes/items/pieces/switch.dts".

don't know of a preload failure could be a problem or not, the object does show up in the world.