Game Development Community

RayCast again

by Howard Dortch · in Torque Game Engine · 04/19/2005 (11:25 am) · 15 replies

Can some one tell me if a CorpseObjectType uses the standing collison box for the player for raycast testing or is the collision box removed on a corpse?

I'm trying to target a corpse like this:


%searchMasks = $TypeMasks::CorpseObjectType ;

%scanTarg = ContainerRayCast (%cameraPoint, %endPoint, %searchMasks);

%scanTarg always returns a 0

I cast rays all over the corpse, below it, above it, at the feet, head and everything in between but it never returns a value other than 0.....

#1
04/19/2005 (11:28 am)
I am almost sure that the collision mesh becomes inactive on death... Hence the reason I can run thorugh the blue guys after they die (they die standing up) ... but dont quote me on that...
#2
04/19/2005 (11:29 am)
You could always create an invisible static shape when the corpse dies, then use that to findthe corpse positions... Remember they fade
#3
04/19/2005 (12:32 pm)
Actually Chris I dont fade them out, they exist in the world long after death. I want the user to be able to target and loot a dead bot. So in order for that I need the body there. I guess I have to write or modify engine code to do this?
#4
08/02/2005 (1:09 pm)
I'm also having this problem. Anyone had any progress or managed to find a work around?
#5
08/02/2005 (1:29 pm)
Create something in it's place and make the fade-out timer activate AFTER you have played around with the created object.
#6
08/02/2005 (2:22 pm)
@Howard
To make the bots/players bodies stay after they die, you do not need to change anything in the engine.

In player.cs around line 900-100 (Mines modified and I don't feel like opening the original :P) find:
function Armor::onDisabled(%this,%obj,%state)
{
   ...

   // Schedule corpse removal.  Just keeping the place clean.
   [b]// And simply comment out these lines, like so
   //%obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true);
   //%obj.schedule($CorpseTimeoutValue, "delete");[/b]
}
Also, it appears that CorpseObjectType is valid (this comes from player.cc):
void Player::updateDamageState()
{
   // Become a corpse when we're disabled (dead).
   if (mDamageState == Enabled) {
      mTypeMask &= ~CorpseObjectType;
      mTypeMask |= PlayerObjectType;
   }
   else {
      mTypeMask &= ~PlayerObjectType;
      [b]mTypeMask |= CorpseObjectType;[/b]
   }

   Parent::updateDamageState();
}
And last but not least, maybe the raycast is not detecting it because of this, in player.cs:
function Armor::onCollision(%this,%obj,%col)
{
   [b]if (%obj.getState() $= "Dead")
      return;[/b]
   
   ...
}

EDIT: More thoughts, look around in the shapeBase.cc and shapeCollision.cc, mostly at queueCollision, I think there might be something there...

Just my thoughts, hope they help.
#7
08/02/2005 (3:38 pm)
Use ContainerRadiusSearch i dont think the corpse return any collision with raycast.
#8
08/04/2005 (12:52 am)
Hi guys, atincjon on irc managed to figure out another way around this by using ContainerCollideBox instead of ContainerRayCast.
#9
08/04/2005 (5:17 am)
Try something like this
function serverCmdCorpseSearch(%client)
{
   %player = %client.player;
   %searchMasks = $TypeMasks::CorpseObjectType;
   %radius = 0.5;
   %pos = %player.getPosition();
   InitContainerRadiusSearch(%pos, %radius, %searchMasks);
  
   while ((%corpse = containerSearchNext()) != 0 ) {
   %dist = containerSearchCurrRadiusDist();
   %target = %corpse.getPosition();
   %id = %corpse.getId();
   %crossbowAmount = %id.getInventory(CrossBow);
   %crossbowAmmo = %id.getInventory(CrossBowAmmo);
      
   echo( "\c1 -- Search Corpse -- " );
   echo( " Distans             = " SPC %dist);
   echo( " Player Pos          = " SPC %pos);
   echo( " Corpse Pos          = " SPC %target);
   echo( " Target Id           = " SPC %id);
   echo( " Amount CrossBow     = " SPC %crossbowAmount);
   echo( " Amount CrossBowAmmo = " SPC %crossbowAmmo);  
   echo( "\c1 - End Search Corpse - " );
  }  
   
}
You need to add soem pickup code.
#10
08/04/2005 (5:30 am)
Neverwinter nights placed a goody bag where the corpse was for looting.. (like Stefan suggested)
That technique might be better performance wise as having high-poly dead player meshes lying around is gonna slow things down eventually.

Deus Ex and "No-one lives forever 2" left the corpse on the floor for looting, made it difficult when there were lots of corpses piled on each other but looked more realistic.

It does look a little odd seeing a corpse replaced by a bag of stuff, but it does make it more obvious that a corpse has something of interest to take.

Depends on how much realism you're going for. You could always limit the number of corpses by only having a set number of active corpses at any one time. Killing a new badguy removes the oldest corpse. (or turns them into a bag if they've got important stuff in their inventory)
#11
08/04/2005 (6:04 am)
A lot of good suggestions but I still would like a way for a player (at some distance) to scan an area with the mouse (raycast) and hilight a target like a corpse. After the corpse is "looted" then fade it out and delete. That was the goal. Container search for a large area like 50 meters away could get frame rate expensive if there were lots of objects in the radius of the search ?
#12
08/04/2005 (7:18 am)
Howard - As I stated before... Use an invisible dummy object, and don't let the corpse fade. You can raycast to find the dummy object and then delete the corpse and the dummy object after you loot it
#13
08/04/2005 (7:28 am)
Howard,

If you want to go with that approach, then simply don't search that far. You can't loot a corpse that's 50 meters away so what's the point?
Just throw a regular raycast at the cursor, and if it collides with a corpseObjectType, return.
#14
08/04/2005 (9:00 am)
@Chris just wouldn't look the same having the dummy object light up instead of the body. That will work just fine for the mechanics but the visuals is what I wanted to look right.
@Stefan didn't say I was going to loot from that far away but the user could scan a heap of rubble and locate the body. In games like Everquest, you kill a mob and you can get an indicator that it is a corpse using the mouse but too far away to loot it. Raycast does not collide with corpseObjectType which was the start of the problem.
#15
08/04/2005 (9:07 am)
Then modify it so it does? Sometimes you have to go in and change stuff.