wierd problem with container raycast
by Bryce² · in Torque 3D Professional · 01/02/2010 (9:49 pm) · 6 replies
ok ill dump my code first
Heres the problem... it only works on 1 of my item datablocks. It picks up the "Juice" item fine, but the "RareJuice" doesn't work.
here are my datablocks
it's been an issue in my game for a while, i gave up on it a few weeks ago, but it has come back to haunt me :(
//------------------------------------------------------------------------------
// RightDown
// This is for starting combat, and looting
//------------------------------------------------------------------------------
function PlayGui::onRightMouseDown(%this, %pos, %start, %ray)
{
%ray = VectorScale(%ray, 1000);
%end = VectorAdd(%start, %ray);
//only search for items
$SearchMasks = $TypeMasks::ItemObjectType;
//get the player name
%player = getPlayer();
//scan the area under the cursor
$scanTarg = ContainerRayCast(%start, %end, $SearchMasks);
//check the scan an perform the corrosponding action
if ($scanTarg)
{
//convert the scan into a variable we can use
%target = firstWord($scanTarg);
//grab the distance between the player and the item
%dist = VectorDist(%player.getPosition(), %target.getPosition());
echo(%dist);
//check if the item is within arms reach and "pick it up"
if (%dist < 5)
{
if( %target.type $= "container" )
{
//%target.pickUp();
Canvas.pushDialog(LootMenu);
populateLoot(%target);
}
else
{
%target.pickUp();
}
}
}
}//onRightMouseDownHeres the problem... it only works on 1 of my item datablocks. It picks up the "Juice" item fine, but the "RareJuice" doesn't work.
here are my datablocks
datablock ItemData(Juice)
{
//category and name
category = "foodDrink";
className = "Drink";
// Basic properties
shapeFile = "art/shapes/items/bottles/juice/juice.dts";
// Dynamic properties defined by the scripts
dispName = "Juice";
};
datablock ItemData(RareJuice)
{
//category and name
category = "foodDrink";
className = "Drink";
//Basic properties
shapeFile = "art/shapes/items/bottles/juice/rareJuice.dts";
//Dynamic properties defined by scripts
dispName = "Rare Juice";
};it's been an issue in my game for a while, i gave up on it a few weeks ago, but it has come back to haunt me :(
About the author
Nimansoft, http://www.nimansoft.com/
#2
I'll try that and post back when i find out if it works.
01/03/2010 (2:10 am)
That sounds like it could be my problem as i made all the objects that don't work :)I'll try that and post back when i find out if it works.
#3
>bounds
>base01
>>start01
>>>Box2
>>>Cylinder2
>>>col-1
>>detail2
>>Collision-0
Thats my setup, got any ideas?
01/03/2010 (4:21 am)
ok it works now thanks for that, but my collision mesh is now the only mesh being rendered.>bounds
>base01
>>start01
>>>Box2
>>>Cylinder2
>>>col-1
>>detail2
>>Collision-0
Thats my setup, got any ideas?
#4
01/03/2010 (9:25 am)
collision-0 should be collision-1. Also make sure force detail isnt set to something causing it not to render. You can find that in the editor
#5
01/03/2010 (7:16 pm)
thanks Adam, ill try it out when i get the chance...
#6
IT WORKS! ty Adam... My nubness continues to suprise me ;)
01/13/2010 (4:38 am)
I know this was a while ago (i forgot about the thread o.O)IT WORKS! ty Adam... My nubness continues to suprise me ;)
Torque Owner Adam Beer
Ignition Games