Tutorial Problem: onCollision
by Joseph Dowling · in Torque Game Engine · 12/21/2005 (1:31 am) · 14 replies
Well, went through the first tutorial without trouble until the end (adding collision to the torquelogoitems). I can't seem to get it working. I've reviewed the tutorial vs. my files several times and went so far as to copy-paste the code from the pdf to the files.
I am fairly positive that I have put them in the right places. When I run into (or jump on top of) a TorqueLogoItem nothing happens, i open the console and see no errors or anything.
If it helps I can post the contents of my files here. Has anyone else had this trouble? I thought at first I was missing a semi-colon or had some of the code in the wrong spot, but I can't find it if that's the case.
Thanks in advance.
I am fairly positive that I have put them in the right places. When I run into (or jump on top of) a TorqueLogoItem nothing happens, i open the console and see no errors or anything.
If it helps I can post the contents of my files here. Has anyone else had this trouble? I thought at first I was missing a semi-colon or had some of the code in the wrong spot, but I can't find it if that's the case.
Thanks in advance.
#2
adding Trace(1); into that file gave me a syntax error. Suppose I'll do some searches as to how to use Trace(1); and that error message.
12/21/2005 (1:54 am)
Acctually i dug up an error: "Warning: Shape GameOne/data/shapes/3dtorquelogo/torque_logo.dts collision detail 0 (collision-1) bounds exceed that of shape."adding Trace(1); into that file gave me a syntax error. Suppose I'll do some searches as to how to use Trace(1); and that error message.
#3
FIrst:
Create a SimGroup (. This is important for keeping "score" later on. Name the Sim group "Logos". select the simgroup and start placing your shapes.
Second:
Did you get the Torguelogodts from or ?
You should make sure you select them from to ensure they work. This maybe the cause of your problem.
Third:
Make sure all your scripts are being loaded - see the console for that.
I use
Hope this helps. Let us know how you get on.
Cheers
edit: clarity
12/21/2005 (4:11 am)
I had that happen too but only after I fiddled with other things...FIrst:
Create a SimGroup (
Second:
Did you get the Torguelogodts from
You should make sure you select them from
Third:
Make sure all your scripts are being loaded - see the console for that.
I use
echo("what am I looking at "@%variableHere); to see how I'm doing with various things. But check the console. Since all *.cs scripts are compiled at run time, if there's a syntax error it will come up in the console. The compiled *.cs file becomes *.cs.dso and you might want to delete those to ensure it's compiling your script fresh.Hope this helps. Let us know how you get on.
Cheers
edit: clarity
#4
run it again and this is what i get in the console:
"Compiling GameOne/server/logoitem.cs...
GameOne/server/logoitem.cs Line: 10 - Syntax error.
*** LOADING MISSION: GameOne/data/missions/gameonemission.mis
*** Stage 1 load
common/server/missionLoad.cs (23): Unable to find function clearCenterPrintAll
common/server/missionLoad.cs (24): Unable to find function clearBottomPrintAll
*** Stage 2 load
Executing GameOne/data/missions/gameonemission.mis.
Object 'TorqueLogoItem' is not a member of the 'GameBaseData' data block class
GameOne/data/missions/gameonemission.mis (0): Register object failed for object logo of class StaticShape.
... repeated several times, one time per torque logo i have in there ...
GameOne/data/missions/gameonemission.mis (0): Register object failed for object logo of class StaticShape.
onNeedRelight: Unknown command.
onNeedRelight: Unknown command.
onNeedRelight: Unknown command.
*** Mission loaded"
Freshly copy-pasted from their respective files:
The tutorial has:
function TorqueLogoItem::onCollision(%this, %obj, %col)
My C:\Torque\SDK\example\GameOne\server\logoitem.cs has on line 10:
function TorqueLogoItem::onCollision(%this, %obj, %col)
I am going to assume that based on the error that I get that "TorqueLogoItem" should read as something else on these lines? Also after opening it and getting those errors now none of my torque logo items show up anymore while they were showing up before.
EDIT: now I don't even have Shapes > Items only Shapes > Misc.
12/21/2005 (11:52 am)
Deleted all the *.dso files, added another logo to make sure I got it from the items subwindow. I had already had a SimGroup made for them titled "logos" (the tutorial wrote the name in all lower case and so did I).run it again and this is what i get in the console:
"Compiling GameOne/server/logoitem.cs...
GameOne/server/logoitem.cs Line: 10 - Syntax error.
*** LOADING MISSION: GameOne/data/missions/gameonemission.mis
*** Stage 1 load
common/server/missionLoad.cs (23): Unable to find function clearCenterPrintAll
common/server/missionLoad.cs (24): Unable to find function clearBottomPrintAll
*** Stage 2 load
Executing GameOne/data/missions/gameonemission.mis.
Object 'TorqueLogoItem' is not a member of the 'GameBaseData' data block class
GameOne/data/missions/gameonemission.mis (0): Register object failed for object logo of class StaticShape.
... repeated several times, one time per torque logo i have in there ...
GameOne/data/missions/gameonemission.mis (0): Register object failed for object logo of class StaticShape.
onNeedRelight: Unknown command.
onNeedRelight: Unknown command.
onNeedRelight: Unknown command.
*** Mission loaded"
Freshly copy-pasted from their respective files:
The tutorial has:
function TorqueLogoItem::onCollision(%this, %obj, %col)
My C:\Torque\SDK\example\GameOne\server\logoitem.cs has on line 10:
function TorqueLogoItem::onCollision(%this, %obj, %col)
I am going to assume that based on the error that I get that "TorqueLogoItem" should read as something else on these lines? Also after opening it and getting those errors now none of my torque logo items show up anymore while they were showing up before.
EDIT: now I don't even have Shapes > Items only Shapes > Misc.
#5
If that's correct, there is probably some sort of script issue. The tutorial was thoroughly tested, so the only real possibilities are 1) one of your files got corrupted or changed somehow or 2) you missed something along the way.
That message from your logoitem.cs is kinda weird. Does the top of that file look like this?
12/21/2005 (2:14 pm)
Just to verify that you got your logos from the right place, make sure that when you create them, it looks like that first screenshot in the PLACING OBJECTS section of the tutorial.If that's correct, there is probably some sort of script issue. The tutorial was thoroughly tested, so the only real possibilities are 1) one of your files got corrupted or changed somehow or 2) you missed something along the way.
That message from your logoitem.cs is kinda weird. Does the top of that file look like this?
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
datablock StaticShapeData(TorqueLogoItem)
{
category = "Items";
shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
};
#7
@Joseph: Have you already checked those two things I suggested?
12/21/2005 (3:56 pm)
@James: Thanks for the [code] tip ;) @Joseph: Have you already checked those two things I suggested?
#8
@ Spider: My pleasure :)
12/21/2005 (6:32 pm)
@ Joseph: I've tried to duplicate the error your getting and can't (I pasted your code into line 10 and it didn't cause a problem). This might sound drastic but I would try building the file again from scratch. There maybe something there that we're all missing. I had that first collision error occur when I first tried putting it together and had trouble discovery what I'd done wrong. I then started to build the script bit by bit to test as I went along and it worked fine. So we're both missing something here (I never discovered the real cause of it). The tutorial works as it's running fine for me now and is the basis for my prototype. Wish I could be more help. Sorry.@ Spider: My pleasure :)
#9
I think my error is quite evident in light of that. Having not really done C++ (or any programming) in a couple years I must have just assumed that by "at the end of the file" it was ment "after the other text before the final };"
It didn't even occur to me to put the added code literally after everything until seeing the above code snippet from Spider... hopefully changing that around fixes it, will test later tonight or tomorrow. Thanks.
EDIT: haha, awesome, completely fixed now and boy do I feel dumb :). Thanks a ton for the help all, that was driving me nuts.
12/21/2005 (10:29 pm)
Logoitem.cs is as follows://-----------------------------------------------------------------------------
// 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);
}
}
};I think my error is quite evident in light of that. Having not really done C++ (or any programming) in a couple years I must have just assumed that by "at the end of the file" it was ment "after the other text before the final };"
It didn't even occur to me to put the added code literally after everything until seeing the above code snippet from Spider... hopefully changing that around fixes it, will test later tonight or tomorrow. Thanks.
EDIT: haha, awesome, completely fixed now and boy do I feel dumb :). Thanks a ton for the help all, that was driving me nuts.
#10
12/21/2005 (10:40 pm)
Oh jeez. Yep, that would do it ;)
#12
datablock()
{
};
function()
{
}
12/23/2005 (12:53 pm)
The function should come AFTER the datablock, not WITHIN the datablock. Should be:datablock()
{
};
function()
{
}
#13
I have an echo command in TorqueLogoItem::onCollision, i.e."echo ("onCollision called");", but that string is not getting printed to the console, so it seems onCollision is *not*getting called when the collision happens.
Anyone else experiencing this?
12/31/2005 (2:04 am)
I have exactly the same problem as Joseph Dowling - however, my ::onCollision function is in the right place. ;^)I have an echo command in TorqueLogoItem::onCollision, i.e."echo ("onCollision called");", but that string is not getting printed to the console, so it seems onCollision is *not*getting called when the collision happens.
Anyone else experiencing this?
#14
It maybe also a good idea to check you've used the logo dts from as the call won't be made if you use the wrong source(?).
01/01/2006 (6:00 am)
As with Joseph, it might help if you show us that code block.It maybe also a good idea to check you've used the logo dts from
Torque Owner Dreamer
Default Studio Name