Game Development Community

Newbie Need Helps,My code is not working

by MARIA SALAZAR · in Technical Issues · 06/16/2008 (9:06 pm) · 16 replies

First, I'm sorry about my english. The Category "myBall" doesn't show in TGE but When I remove datablock TSShapeConstructor, The Category "myBall" appears in the Tree and Everything is working fine in ShowTool but It is not working in TGE . Thank you so much

datablock TSShapeConstructor(myball){
baseShape = "~/data/shapes/superbomb/myball.dts";
sequence0 = "~/data/shapes/superbomb/myball.dsq root";
};

datablock StaticShapeData(myball)
{
category = "myBall";
shapeFile = "~/data/shapes/superbomb/myball.dts";
};


function myball::onAdd(%this,%obj)
{
%obj.playThread(0,"root");
}


//another question : %obj.playThread(0,"root"); what does "0" refer to ? Does it my loops ?

#1
06/17/2008 (7:09 am)
You do not need to add the data/shapes/ in each of the sequences. You need to make sure you have everything named EXACTLY right or else torque will not recognize it. To make things simple, call your ball myball.

You should have the myball.cs file located in your player or in your case ball shape folder. Your datablock should look something like this:


datablock TSShapeConstructor(myballDts)
{
   baseShape = "./myball.dts";
   sequence0 = "./myball.dsq root";
};

The rest of the coding looks good. Try what I said and let me know if that worked.
#2
06/17/2008 (11:40 am)
Thank for you help but it is still not working. the problem now is i cannot find "myBall" catagory in my shapes tree in world editor so I cannot bring my ball to the game world. I really don't know why. But when I remove the TSShapaeConstructor code I can find "myBall" catagory in the shapes tree. This is my code now

//myball.cs located in myball.cs folder
datablock TSShapeConstructor(myball)
{
baseShape = "./myball.dts";
sequence0 = "./myball.dsq root";
};

//myball.cs located in server
exec("~/data/shapes/superbomb/myball.cs");

datablock StaticShapeData(myball)
{
category = "myBall";
shapeFile = "~/data/shapes/superbomb/myball.dts";
};


function myball::onAdd(%this,%obj)
{
%obj.playThread(0,"root");
}
#3
06/17/2008 (6:38 pm)
Well, then take the code out if that works.

I'm not sure about this, because I'm not sure which SDK you are using. I wasn't aware any SDK came with a ball game mode. I looked over my player.cs for a staticshapedata and there is nothing in there like that. I use TGE 1.5.2.

Let me know what you are using and I'll try to help you out more.

Are you wanting the ball to be the player or just show up in the world editor as an object?
#4
06/17/2008 (6:44 pm)
Do you have a dsq file named myBall.dsq?? With an animation named root?
#5
06/17/2008 (10:46 pm)
Dustin
I'm using TGE 152 too and I just want to make an animation object like boucing ball.

Mike
I have myball.dsq but I don't think I have an animation named root. I just made and sequence named "sequence01" and exported it. Did I miss some steps ? How do I make an animaiton named root?

Thank you for helping me
#6
06/18/2008 (7:25 am)
Okay.

To make an animation for the root you will need to create one in milkshape(not expensive) or 3ds (extremely expensive). If you didn't do this, your ball will not move. You can still use it though, just it will slide around the level awkwardly.

If you use milkshape, you will need the lastest version. Import your model, animate it, and then export it with torque dts plus exporter in milkshaper and make sure you check export animation as well. I can't really go over how to do this, but check youtube.com and they will probably have a better example of how to do it rather than me writing it out.

Sound to me the reason it isn't showing up is that the myball.cs located in the server(starter.fps/server/scripts) is not executed.

Go to game.cs, open it, and then with the others, type exec("./myball.cs");

That should work.
#7
06/18/2008 (2:33 pm)
Thank you Dustin, I am using 3DS. I put myball.cs in tutorial.base/server and I put exec("./myball.cs"); in game.cs already. I think the problem is about exporting animation. The way I did was

1. In the same DTS file, I create sequence animation in 3ds named "sequence01" start at frame 1.
my root pose is frame 0
2. export sequence.


http://www.garagegames.com/docs/tge/general/ch08s02.php << this is my DTS and DSQ resource.


I don't know I miss some steps or not. I just read some tutorial and combine it. and I don't know why it works in show tool

I'm still confused what Mike said "Do you have a dsq file named myBall.dsq?? With an animation named root?"
what is the animation named root?

Thank you so much
#8
06/18/2008 (5:49 pm)
To answer the question:

Well, do you have a file called myball.dsq in your data/shapes/player(or ball whatever you have)?

Do you have a file called root.dsq? In your ball.cs (data/shapes/player(or ball whatever you have)?
#9
06/18/2008 (6:45 pm)
What Dustin said.
You list 2 dsq files in your script. You will need both for it to work.
#10
06/18/2008 (7:13 pm)
I have this in the /player folder to call myball.dsq and this is script in the myball.cs file

datablock TSShapeConstructor(myball)
{
baseShape = "./myball.dts";
sequence0 = "./myball.dsq root";
};

I think the problem comes from the code above because without that code I can find myball catagory in the shapes tree or It comes from the way that I export the animation so I have questions
- Do I have to name my sequence animation ? I didn't name it
- Do I have to save my file to myball_root.dsq instead of myball.dsq?

It does work in ShowTool and torque.exe -show. If I did something wrong It should not work in showtool so I am so confused now. I typed playThread(); in the consold and It said "unable to find function playTread"


I have only one .dsq file, myball.dsq but I don't have root.dsq. Do I need 2 dsq ,root.dsq and myball.dsq ? I guess I missed something. I think I will find some tutorials about how to make animations. Can you tell me where can I find it ? Because I cannot find it so I have to come up by my guess.

Thank you for helping me
#11
06/19/2008 (8:30 am)
Ok, baseshape means your ball.dts file. It should be your ball shape located in (data/shapes/player(or ball whatever). So that is correct.

sequence0 means your animation that you made where the ball moves or whatever you made. I assume you named it myball.dsq. If you did not name it, it should be renamed to that. It should also be located in (data/shapes/player(or ball whatever).

datablock TSShapeConstructor(myball)
{
baseShape = "./myball.dts";
sequence0 = "./myball.dsq root";
};
#12
06/19/2008 (11:34 am)
Thank you Dustin, If you don't mind Can you check my file please. This is the link to download my file

http://download.yousendit.com/EED3B2275DF3585E

I try to rename and everything but It didn't work. I don't know why the animation play in showtool but
not in the engine.

Thank you so much
#13
06/21/2008 (8:20 am)
Your ball.cs should look like this:


//-----------------------------------------------------------------------------

// Torque Game Engine

// Copyright (C) GarageGames.com, Inc.

//-----------------------------------------------------------------------------


datablock TSShapeConstructor(myball)

{

baseShape = "./myball.dts";

sequence0 = "./myball.dsq root";



};



datablock StaticShapeData(myball)

{

category = "myball";

shapeFile = "~/data/shapes/superbomb/myball.dts";

};



function StaticShapeData::create(%block)

{

%obj = new StaticShape()

{

dataBlock = %block;

};

return(%obj);

}
#14
06/22/2008 (4:23 pm)
Thank you Dustin. Unfortunately, I cannot make it happen. I don't know why I can create my own character and It can play my own animation but I cannot do it with the simple shape. I think I might do simple animation with script instead.
#15
06/22/2008 (4:55 pm)
I got it!!!!!!!!!!!!!!!!!!!
It plays my animation already Thank you so much for helping me. I think my problem is TSShapeConstructor datablock. when I remove it from myball.cs It works.
#16
06/23/2008 (8:57 am)
I'm glad you got it working.