Collision (Torque logo item - Player)
by Lukas Joergensen · in Torque Game Engine · 01/20/2009 (6:08 am) · 2 replies
Hi, i have been working on this issue in quite a long time and can't fix it on my own so hoping for a little help here ;)
I try to make a game like the GameOne in "Getting Started.PDF" but i keep having this problem tried everything that came to my mind:
When the player collide with a Torque Logo Item the item should be destroyed. But it doesn't. When i run into it with the player object it just blocks the path. I have tried several solutions none of them worked. I tried moving the function to be player based and i tried removed the additional script and i tried making the Torque Logo Item both as a ItemData datablock and as a ShapeBaseData
The codes i used was a copy of Tutorial base with a little bit of code added:
in server/ToqueLogoItem.cs
datablock StaticShapeData(RedTorqueLogoItem)
{
category = "Items";
shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
};
function TorqueLogoItem::onCollision(%this, %obj, %col)
{
if(%col.getClassName() $= "Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount > 0)
return;
// otherwise display victory screen
commandToClient(%client, 'ShowVictory', %client.score);
}
}
And in client/clientGame.cs
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}
I try to make a game like the GameOne in "Getting Started.PDF" but i keep having this problem tried everything that came to my mind:
When the player collide with a Torque Logo Item the item should be destroyed. But it doesn't. When i run into it with the player object it just blocks the path. I have tried several solutions none of them worked. I tried moving the function to be player based and i tried removed the additional script and i tried making the Torque Logo Item both as a ItemData datablock and as a ShapeBaseData
The codes i used was a copy of Tutorial base with a little bit of code added:
in server/ToqueLogoItem.cs
datablock StaticShapeData(RedTorqueLogoItem)
{
category = "Items";
shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
};
function TorqueLogoItem::onCollision(%this, %obj, %col)
{
if(%col.getClassName() $= "Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount > 0)
return;
// otherwise display victory screen
commandToClient(%client, 'ShowVictory', %client.score);
}
}
And in client/clientGame.cs
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}
About the author
IPS Bundle available at: https://www.winterleafentertainment.com/Products/IPS.aspx
#2
01/20/2009 (11:44 am)
Figured that out, just found the bug a minute ago. It was because i misunderstood the mission editor, didn't knew it both loaded shapes with and without a datablock, so there were two entries of the Shape and i did create the non scripted one.
Associate Michael Hall
Distracted...
The onCollision callback Namespace isn't referencing your object's datablock, so what happens is that when you collide with your shape there is nothing being done to/with it.
try: function RedTorqueLogoItem::onCollision() instead.