Torque tutoral
by Jermaine Morgan · in Torque Game Engine · 07/27/2006 (9:16 pm) · 15 replies
I am still playing around with the torque getting started tutorial. The "GameOne tutorial"
its suppose to show how to make the score go up a point when u collide with a torque logo but when i play the game i collide with the logo but the score never goes up.
this is the code for the logoitem.
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
datablock StaticShapeData(TorqueLogoItem)
{
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);
}
}
can anyone help?
its suppose to show how to make the score go up a point when u collide with a torque logo but when i play the game i collide with the logo but the score never goes up.
this is the code for the logoitem.
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
datablock StaticShapeData(TorqueLogoItem)
{
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);
}
}
can anyone help?
About the author
#2
07/27/2006 (10:02 pm)
Thanks but that didnt really work
#3
07/28/2006 (8:05 am)
Hello
#4
www.garagegames.com/mg/forums/result.thread.php?qt=38098
07/28/2006 (11:29 am)
Look into this other forum post for the same problem..www.garagegames.com/mg/forums/result.thread.php?qt=38098
#5
can any one help?
Is anybody else having this issue?
07/28/2006 (9:24 pm)
Thanks, but i have read that topic over 3 times and i just cant get it to work.can any one help?
Is anybody else having this issue?
#6
07/28/2006 (10:10 pm)
Maybe the code that makes the score go up, is at flaw....
#7
If your score counter doesn't work, try using integers like:
//at the start of your .cs file
$logoCount = 0;
..........................
..........................
//in your onCollision Code
$logoCount++;
..........................
Then just make your GUI print out $logoCount.
07/29/2006 (7:26 am)
Make sure that when you add the torque logo object that you added it under the shapes/Item list and not the static shapes. If it still doesn't work, try this, remove or comment out ever thing in the onCollision function that does not have to do with collision, it should now look like this:function TorqueLogoItem::onCollision(%this, %obj, %col)
{
if(%col.getClassName() $= "Player")
{
//test to make sure it worked
echo("picked up logo");
%obj.delete();
}
}If your score counter doesn't work, try using integers like:
//at the start of your .cs file
$logoCount = 0;
..........................
..........................
//in your onCollision Code
$logoCount++;
..........................
Then just make your GUI print out $logoCount.
#8
07/29/2006 (8:02 am)
Shouldn't it be %client.incScore(1);
#9
07/30/2006 (9:35 pm)
I'd say check spelling. Was having this problem and I had a typo in my Score Counter.
#10
08/02/2006 (8:07 pm)
Check the console for compile errors with your scripts
#11
my error in the console only says
"cyclemissions: unknown command" and there is another error way back up in there that says that my mission has no mission group??
i even copied and pasted the exact code into the script so as to rule out the chance of error and its still happening...
08/28/2006 (12:17 am)
Im having problems with this too, only my game freezes on the connecting to server screen.my error in the console only says
"cyclemissions: unknown command" and there is another error way back up in there that says that my mission has no mission group??
i even copied and pasted the exact code into the script so as to rule out the chance of error and its still happening...
#12
You know how when you're first setting up that ScoreCounter in the GUI editor? Well, they have us set it as "Score: 0".
I think that maybe if we had "Score: " and "0" seperately, where "Score: " would be nothing more than a constant of text-display, and then increment the "0" (whatever you name it) when the collision is detected, then you can probably make it go up. I hope this makes sense, but again, I haven't been back home yet to actually test this.
09/01/2006 (1:04 pm)
Dude, I just had that same problem, and I think I may have just now thought of the solution, but I haven't been able to test it out yet, since I'm at school... Here is what I'm thinking:You know how when you're first setting up that ScoreCounter in the GUI editor? Well, they have us set it as "Score: 0".
I think that maybe if we had "Score: " and "0" seperately, where "Score: " would be nothing more than a constant of text-display, and then increment the "0" (whatever you name it) when the collision is detected, then you can probably make it go up. I hope this makes sense, but again, I haven't been back home yet to actually test this.
#13
I want to post it.
I made the mistake f putting a space for score counter
Score Counter
that is with a space^
no space is needed it should be
ScoreCounter.
No Space^
Just for the people who never found the answer
03/24/2007 (9:31 pm)
SORRY for the massive bump but i just want to say I have found the answer to this problem.I want to post it.
I made the mistake f putting a space for score counter
Score Counter
that is with a space^
no space is needed it should be
ScoreCounter.
No Space^
Just for the people who never found the answer
#14
Good job on finding the problem. I have to say it's quite a shame when you get stumped and waste time due to a spelling mistake - we all do it! But I would heartily recommend you start using a TorqueScript IDE like Torsion. Torsion will check your syntax for you and will help minimise some syntax errors that would otherwise be a pain to find. It would have certainly found your particular problem, saving you a lot of time and headache.
--Amr
03/25/2007 (4:05 am)
Hello Jermaine,Good job on finding the problem. I have to say it's quite a shame when you get stumped and waste time due to a spelling mistake - we all do it! But I would heartily recommend you start using a TorqueScript IDE like Torsion. Torsion will check your syntax for you and will help minimise some syntax errors that would otherwise be a pain to find. It would have certainly found your particular problem, saving you a lot of time and headache.
--Amr
#15
Being a vb.net programmer i should have been expecting it would have been something simple.
03/25/2007 (7:38 am)
Yes i just got curious last night. It took me about 2 hours to figure it out.Being a vb.net programmer i should have been expecting it would have been something simple.
Torque 3D Owner Jesse Liles
... function TorqueLogoItem::onCollision(%this, %obj, %col) { [b]echo(%col.getClassName());[/b] if (%col.getClassName() $= "Player") ...to make sure the class name is actually "Player"