TGB Dismount issue
by Jay Rakestraw · in Technical Issues · 02/24/2007 (6:22 pm) · 2 replies
Hello,
I am a student using TGB, and have stumbled upon a problem with my scripting. Our game is a top down puzzle based game. We are using objects (such as the twig referenced in code below) to solve the puzzles. I was hoping for the object to dismount directly in front of the player character, but it dismounts and radomly places. (It picks up the item just as planned, but the issue is purely dismount.)
Any suggestions?
Here is script:
// Called by player.cs when spacebar is pressed within
// an item trigger.
function playerChar::mountItem(%this, %itemTrigger)
{
%item = %itemTrigger.getMountedParent();
%item.setCollisionActive(0,0);
%item.mount($pChar);
%itemTrigger.setCollisionActive(0, 0);
$carrying = 1;
$carryingNumber = %item;
$carryingType = %itemTrigger.itemType;
$carryingTrigger = %itemTrigger;
}
function playerChar::dismountItem(%this, %item)
{
$offsetX = 0.2;
$offsetY = 0.2;
%item.dismount();
if ($rotation $= "left")
{
%item.setPositionX($pChar.getPositionX - $offsetX);
}
else if ($rotation $= "right")
{
%item.setPositionX($pChar.getPositionX + $offsetX);
}
else if ($rotation $= "down")
{
%item.setPositionY($pChar.getPositionY + $offsetY);
}
else if ($rotation $= "up")
{
%item.setPositionY($pChar.getPositionY - $offsetY);
}
$carrying = 0;
$carryingNumber = 0;
$carryingType = "nothing";
%item.setCollisionActive(0,1);
$carryingTrigger.setCollisionActive(0, 1);
}
Thanks.
I am a student using TGB, and have stumbled upon a problem with my scripting. Our game is a top down puzzle based game. We are using objects (such as the twig referenced in code below) to solve the puzzles. I was hoping for the object to dismount directly in front of the player character, but it dismounts and radomly places. (It picks up the item just as planned, but the issue is purely dismount.)
Any suggestions?
Here is script:
// Called by player.cs when spacebar is pressed within
// an item trigger.
function playerChar::mountItem(%this, %itemTrigger)
{
%item = %itemTrigger.getMountedParent();
%item.setCollisionActive(0,0);
%item.mount($pChar);
%itemTrigger.setCollisionActive(0, 0);
$carrying = 1;
$carryingNumber = %item;
$carryingType = %itemTrigger.itemType;
$carryingTrigger = %itemTrigger;
}
function playerChar::dismountItem(%this, %item)
{
$offsetX = 0.2;
$offsetY = 0.2;
%item.dismount();
if ($rotation $= "left")
{
%item.setPositionX($pChar.getPositionX - $offsetX);
}
else if ($rotation $= "right")
{
%item.setPositionX($pChar.getPositionX + $offsetX);
}
else if ($rotation $= "down")
{
%item.setPositionY($pChar.getPositionY + $offsetY);
}
else if ($rotation $= "up")
{
%item.setPositionY($pChar.getPositionY - $offsetY);
}
$carrying = 0;
$carryingNumber = 0;
$carryingType = "nothing";
%item.setCollisionActive(0,1);
$carryingTrigger.setCollisionActive(0, 1);
}
Thanks.
#2
03/30/2007 (4:03 pm)
Good find, also be sure to check out the TGB Public and Private forums for any future questions, posts, or problems :)
Torque Owner The Guildhall at SMU (#0002)
Must have () after the .getPositionX and Y