Detecting if players is indoors (Need Help)
by Jorge Luis Gandulfo · in Torque Game Engine · 01/19/2006 (8:28 pm) · 7 replies
I wanted to detect when a player is indoors.
Why i need this, well i have several Shots SFX from a Glock for example, from outdoors and indoors shooting, and i wanted to play the proper sound, to add some more realism to my project.
Maybe there is a way to know when a player have entered a building, hope there is, otherwise i will have to think some way to solve this.
Thanks a lot
Why i need this, well i have several Shots SFX from a Glock for example, from outdoors and indoors shooting, and i wanted to play the proper sound, to add some more realism to my project.
Maybe there is a way to know when a player have entered a building, hope there is, otherwise i will have to think some way to solve this.
Thanks a lot
#2
Seems i have to do some playing arround with the engine now :).
01/19/2006 (8:51 pm)
Thanks for the tip.Seems i have to do some playing arround with the engine now :).
#3
01/19/2006 (9:25 pm)
Naw, a raycast is very simple. It can be done 100% in script. Here a snippit from my code!%player = %client.player;
%eye = %player.getEyeVector();
%vec = vectorScale(%eye, 200);
%startPoint = %player.getEyeTransform();
%endPoint = VectorAdd(%startPoint,%vec);
%searchMasks = $TypeMasks::VehicleObjectType; //You can do InteriorObjectType
%object = ContainerRayCast (%startPoint, %endPoint, %searchMasks, %player);
if(%player.isMounted == false)
{
if(%object)
{
//echo("Maybe we have something?");
//If its an interior type, maybe run a check such as
// %pie = %object.getID();
// if(%pie.isBuilding == "1") { DO STUFF}
onMountVehicle(%vehicle, %player, %object.getID());
%player.mounted = %object.getID();
%player.isMounted = true;
}
if(!%object)
{
//echo("No Bites Yet");
}
}
else {
onPlayerDismount(%vehicle, %player, %player.mounted);
//echo("Your Mounted! OMGASH");
}
// echo(%object); (The Echo Statements, are just for debugging purposes.)
#4
01/20/2006 (6:01 am)
You could also just setup triggers at the entrances of the buildings that toggle an indoor/outdoor flag.
#5
On the other hand the problem of raycasting is start and end points, i think the best way to check if you are inside a building is raycasting from a position over the player, down to the player, or vice versa (Mostly to check for a roof presence).
Becouse if you are outside a building pointing at it, and you raycast from the eye, the program will assume you are indoors.
Thanks Chris for the example BTW.
01/20/2006 (7:03 am)
Well triggers are great idea, but they will force me to put a trigger on every building, and to set a clear this flags in a lot of situations like death.On the other hand the problem of raycasting is start and end points, i think the best way to check if you are inside a building is raycasting from a position over the player, down to the player, or vice versa (Mostly to check for a roof presence).
Becouse if you are outside a building pointing at it, and you raycast from the eye, the program will assume you are indoors.
Thanks Chris for the example BTW.
#6
bool InteriorInstance::getPointInsideScale(const Point3F & pos, F32 * pScale) in interior/interiorInstance.cc
01/20/2006 (4:36 pm)
You should take a look atbool InteriorInstance::getPointInsideScale(const Point3F & pos, F32 * pScale) in interior/interiorInstance.cc
#7
01/22/2006 (11:31 pm)
Thanks a lot Matt, i was too busy separating server and client code to check this out , i will test this when i wake up
Torque 3D Owner Peter Simard
Default Studio Name