HELP! Want to start coding stuff up
by Jonathan Morin · in Torque Game Engine · 06/08/2005 (10:29 pm) · 18 replies
Ok. I read through the demos and examples. I'm not interested in using the scripting engine at the moment. I have already built the library and linked it into my project. I would like to start using the Torque Lib in my code but I don't know where to start. How do I initialize it? What do I call to load a model? How do I call the networking code? Does anyone have a sample application that does any of this? I would love to get my hands on it. I learn better by reading sample code. But just reading the engine is kind of a pain for a starting point. :) Sorry if I am asking so many questions. I'm not used to using a third party game engine. At the previous company I was at we always wrote our own, but now I don't have the time or resources to write my own. Any help anyone can offer would be greatly appreciated.
-Jon-
-Jon-
#2
What really helped me though, was having an idea and a desire to achive something first.
I wanted to have a static camera. It seems almost too simple, but just try it and you will learn a hell of a lot about torque. Then I got that fixed. And now I am working on maps and physics. Its great fun! And I am learning heaps about torque!
Believe me, start really small and try playing around with the starter.fps or starter.racing and think "what do I want to achive". Its always easy to pull and icarus and fly too high.
"EDIT: If you want to see the flow of the eninge... start looking at the main.cs scripts in the example folder." - That is a good tip to see where it all branches from.
Personally I started at car.cs but I was playing around with starter.racing. If you start with starter.fps, play around with player.cs. But yeah main.cs gives you a good idea of where everything else branches from.
I can believe how easy it is to read and follow.
06/09/2005 (5:10 am)
I tell you what. I have found the basic starter.racing example invaluable in learning torque.What really helped me though, was having an idea and a desire to achive something first.
I wanted to have a static camera. It seems almost too simple, but just try it and you will learn a hell of a lot about torque. Then I got that fixed. And now I am working on maps and physics. Its great fun! And I am learning heaps about torque!
Believe me, start really small and try playing around with the starter.fps or starter.racing and think "what do I want to achive". Its always easy to pull and icarus and fly too high.
"EDIT: If you want to see the flow of the eninge... start looking at the main.cs scripts in the example folder." - That is a good tip to see where it all branches from.
Personally I started at car.cs but I was playing around with starter.racing. If you start with starter.fps, play around with player.cs. But yeah main.cs gives you a good idea of where everything else branches from.
I can believe how easy it is to read and follow.
#3
06/09/2005 (5:16 am)
I realize scripting is how you do things in Torque. But I really don't want to write a game using purely scripts. Scripting should be used to enhance a game and allow any developer to add content into a game, thus allowing the programmers more time to add cooler things to the game. I'm used to getting down into the game code and writing the components of the game. I feel that with scripting I am limited and if I want to make a change I will have to modify code that is called through a scripting engine. Who knows if the scripting engine is able to handle the particular change. Thus makinig debugging hell. Maybe this engine is not what I am looking for, though it looks great and has wonderful abilities. I have different needs as far as networking goes as well, and I don't want to be stuck with doing it one way because I have to use scripts. If you can clarify anything for me or give me any suggestions or direction it would be greatly appreciated. I am in the process of creating a mock up for a publisher. Maybe I can use this to do that for now.
#4
Your engine changes get made in the engine... some things you will want to do in script. it's just easier... like high level ai functions... later if you want to you can transfer that to C++ code, but its better just to leave it in script...
I was in your position when I came into Torque. I realized that Torque already did what I wanted to do, and did it better... all I had to do was start altering things a little bit to suit myneeds.
Scripting is how you set up your world. You can script other htings like an inventory system or high level ai in it as well. You can do that stuff in C++ engine code, but it is easier to do it inscript (for several reasons) ... You can convert it over from the script to c++ after its finished if you want to, but its easier to do it in script.
Your game wont be written entirely in script... A lot of the gmae logic itself might be... but most of hte games funcitoning (98%) will be in the engine source, of which 90% of it is already done... You just need to start modifying the engine source, and scripting hte logic...
06/09/2005 (5:25 am)
Well, 90% of what you want to do is already done in Torque... You cna get into source andchange the other 10%... You can strip Torque to bare essentials, but you dont want to, trust me. . . Your engine changes get made in the engine... some things you will want to do in script. it's just easier... like high level ai functions... later if you want to you can transfer that to C++ code, but its better just to leave it in script...
I was in your position when I came into Torque. I realized that Torque already did what I wanted to do, and did it better... all I had to do was start altering things a little bit to suit myneeds.
Scripting is how you set up your world. You can script other htings like an inventory system or high level ai in it as well. You can do that stuff in C++ engine code, but it is easier to do it inscript (for several reasons) ... You can convert it over from the script to c++ after its finished if you want to, but its easier to do it in script.
Your game wont be written entirely in script... A lot of the gmae logic itself might be... but most of hte games funcitoning (98%) will be in the engine source, of which 90% of it is already done... You just need to start modifying the engine source, and scripting hte logic...
#5
06/09/2005 (5:30 am)
Perhaps if you stated what you want to do with Torque, it would be easier to tell if it is right for you. Or how you would want to go about making the changes to torque
#6
06/09/2005 (6:07 am)
I want to use Torque for the 3D rendering and it's ability to create UI quickly through scripting (which I can have my designer do while I am working on the game content). I want to write my own game logic and not have to rewrite or modify someone elses code. I'm sure the AI system works great for what it was intended, but I have another programmer working on a new type of AI system, which requires writing it all from scratch and not having to figure out how to get it to work in the Torque AI system. If I had the resources and time I would write my own 3D engine (which I was working on until recently). I decided I wanted the game to be completed within 2 years as opposed to 3 or 4 years because I was writing my own 3D engine. I want to create a mockup for the current idea my partners and I have and that is why a middleware engine sounded more like what I wanted. I'm not sure if Gamebryo, Renderware or other engines are like Torque in that you do everything thru scripting. I can't believe that they are. But they also cost 500 times the cost of Torque. I'm just afraid after I get a publisher, we will want to switch over to Renderware or the such and we will have to completely rewrite everything as it will have all been done in scripts. That's where I am right now. Sorry if I sound mad or frustrated. I'm just VERY frustrated as this is the 3rd engine I have tried this week. I also spent a few hours today rewritng the project files and getting the Torque engine to link into my code. Argggh. hehe.
#7
You seem to have a good understanding of what should be in scripts and what should be in the engine itself and your definition is exactly the way Torque works. Torque doesn't tie you to any one way of doing things. There is a tictactoe demo on the site somewere that was developed almost completely in c++ but I don't recommend you do that.
So here is how I look at torque. Essentially, rendering, physics, colition detection, networking or even high level definitions such as cars all go in the engine itself or anything else that is required and/or is mathmatically entencive.
Scripting is were you define what action it's going to take when something happens. For example, as soon as something colides then it calls the script that is assotiated with that object and calls onCollide.. So you can put in there blow up or what ever you want. You also want to keep any type of tweakable setting in the scripts so you don't have to recompile because the player has to much gravity applied to him or what ever problem you come up with.
You also want to keep your game logic in the scripts because its a lot easier to work with and can be easily modified until you are happy with the results.
Now, I know you are thinking well what if the scripting language can't handle what I want. Well the good news is that is not the case. When you create your c++ object, you define what is going to be static information (applied to all objects of this type), and you can create consoleMethods to access that object in anyway you want. As if you were doing it from code. You can also define what networking information is going to be sent and when its need to be sent. Once you have the object defined and sending information the way you want, then you just create to object in your scripting language and use a datablock to define the static information and it all matically happens.
So you can create any component you want, for example the fx stuff from melv and then just new it in the scripting language and you can use it anyway you want.
Hope that helps, from your statements I know that Torque does exactly what you want but it does take some getting us to. Check out the fx stuff and the tictactoe demo.
Ben
06/09/2005 (6:15 am)
Hello Jonathan,You seem to have a good understanding of what should be in scripts and what should be in the engine itself and your definition is exactly the way Torque works. Torque doesn't tie you to any one way of doing things. There is a tictactoe demo on the site somewere that was developed almost completely in c++ but I don't recommend you do that.
So here is how I look at torque. Essentially, rendering, physics, colition detection, networking or even high level definitions such as cars all go in the engine itself or anything else that is required and/or is mathmatically entencive.
Scripting is were you define what action it's going to take when something happens. For example, as soon as something colides then it calls the script that is assotiated with that object and calls onCollide.. So you can put in there blow up or what ever you want. You also want to keep any type of tweakable setting in the scripts so you don't have to recompile because the player has to much gravity applied to him or what ever problem you come up with.
You also want to keep your game logic in the scripts because its a lot easier to work with and can be easily modified until you are happy with the results.
Now, I know you are thinking well what if the scripting language can't handle what I want. Well the good news is that is not the case. When you create your c++ object, you define what is going to be static information (applied to all objects of this type), and you can create consoleMethods to access that object in anyway you want. As if you were doing it from code. You can also define what networking information is going to be sent and when its need to be sent. Once you have the object defined and sending information the way you want, then you just create to object in your scripting language and use a datablock to define the static information and it all matically happens.
So you can create any component you want, for example the fx stuff from melv and then just new it in the scripting language and you can use it anyway you want.
Hope that helps, from your statements I know that Torque does exactly what you want but it does take some getting us to. Check out the fx stuff and the tictactoe demo.
Ben
#8
Why the heck would you license a fully featured game engine if you didn't want to rewrite or modify someone elses code. If all you want is a rendering engine then you are best off looking else where. Look for a 3D engine, not a game engine.
If you were smart you would utilize and rework the TGEcodebase. There is no built in AI system really. Writing a new one wouldnt take long... But, to strip out everything down to a rendering layer would take you about as much time as it would to write your own.
Torque is a game engine, not a rendering engine. If I were you, I would either be smart and rework the TGE code base, building my game on torque (as it was built for doing that) or switch to a rendering engine.
06/09/2005 (6:16 am)
"I want to write my own game logic and not have to rewrite or modify someone elses code"Why the heck would you license a fully featured game engine if you didn't want to rewrite or modify someone elses code. If all you want is a rendering engine then you are best off looking else where. Look for a 3D engine, not a game engine.
If you were smart you would utilize and rework the TGEcodebase. There is no built in AI system really. Writing a new one wouldnt take long... But, to strip out everything down to a rendering layer would take you about as much time as it would to write your own.
Torque is a game engine, not a rendering engine. If I were you, I would either be smart and rework the TGE code base, building my game on torque (as it was built for doing that) or switch to a rendering engine.
#9
06/09/2005 (6:32 am)
Thank you for you response Ben. That does help me. As per the flame from Chris. I've been in the game industry for over 8 years and have shipped multiple AAA titles. I'm just a bit frustrated and looking for some help on how to use Torque for what I need. I guess looking at all the examples scared me a bit. I was afraid I would be stuck doing everything thru scripts.
#10
flame ? I wasn't flaming you. You must have really thin skin if you took what I said offensively. I appologize if I was out of line but I dont think I was.
It's true that if you don't want to touch any of the code alredy in the TGE, then you should look for a rendering engine. However, if you want to use the power TGE offers you are going to have to alter and/or rewrite some of what is there. You can't change TGE's functionality if you don't.
EDIT: You try and help someone and they think you're flaming... State something I said that wasn't true. A flame would be a direct attack of your person or statements.
06/09/2005 (6:43 am)
"As per the flame from Chris" flame ? I wasn't flaming you. You must have really thin skin if you took what I said offensively. I appologize if I was out of line but I dont think I was.
It's true that if you don't want to touch any of the code alredy in the TGE, then you should look for a rendering engine. However, if you want to use the power TGE offers you are going to have to alter and/or rewrite some of what is there. You can't change TGE's functionality if you don't.
EDIT: You try and help someone and they think you're flaming... State something I said that wasn't true. A flame would be a direct attack of your person or statements.
#11
I was weary of using scripts at first too. I had the same idea of "the meat and potatoes" of the game should be hardcoded and scripting should be for npc dialog, little critters crawling along in the environment, water effects etc.. That a REAL engine uses hardcode. It would seem as though scripting most of the code is adding another layer, and removes you from the actual business end that does the work. There is a reason for this thinking. If you are using other engines, that is the way it is done.
But with torque, scripting isn't "another layer" ( I suppose technically it is, but it isn't treated as such) to remove you from what is really going on. The scripting is part of the engine, and unless you are worried about hardcore code changes (additional functionality, rendering methods, whatever), you won't need to touch the source code at all. There will be times when you do need to touch the source code, as it doesn't do _everything_ but it does alot already. In fact, torquescript allows you to do what you asked about in the original post, and in much fewer lines of code than in C++.
There are good tutorials all over the net, one that I found helpful is over at codesampler (check the resources section for the link). They give you a chunk of script at a time, specific to the task it's trying to implement.
If you don't want to use torquescript, but maybe python instead, there are ways to do this. But I think even with that, it's python _alongside_ of torquescript (I haven't played with it, so I don't know).
Once you accept scripting, learning torque will be much easier for you. If one were to hold the belief that the engine were a black box, and the only way to communicate with it was with script, they could still make a game, and with more success than one trying to avoid the script and understands the inside of the box.
Good luck!
06/09/2005 (6:44 am)
Jon,I was weary of using scripts at first too. I had the same idea of "the meat and potatoes" of the game should be hardcoded and scripting should be for npc dialog, little critters crawling along in the environment, water effects etc.. That a REAL engine uses hardcode. It would seem as though scripting most of the code is adding another layer, and removes you from the actual business end that does the work. There is a reason for this thinking. If you are using other engines, that is the way it is done.
But with torque, scripting isn't "another layer" ( I suppose technically it is, but it isn't treated as such) to remove you from what is really going on. The scripting is part of the engine, and unless you are worried about hardcore code changes (additional functionality, rendering methods, whatever), you won't need to touch the source code at all. There will be times when you do need to touch the source code, as it doesn't do _everything_ but it does alot already. In fact, torquescript allows you to do what you asked about in the original post, and in much fewer lines of code than in C++.
There are good tutorials all over the net, one that I found helpful is over at codesampler (check the resources section for the link). They give you a chunk of script at a time, specific to the task it's trying to implement.
If you don't want to use torquescript, but maybe python instead, there are ways to do this. But I think even with that, it's python _alongside_ of torquescript (I haven't played with it, so I don't know).
Once you accept scripting, learning torque will be much easier for you. If one were to hold the belief that the engine were a black box, and the only way to communicate with it was with script, they could still make a game, and with more success than one trying to avoid the script and understands the inside of the box.
Good luck!
#12
06/09/2005 (6:53 am)
Thank you for you response Ben. That does help me. As per the flame from Chris. I've been in the game industry for over 8 years and have shipped multiple AAA titles. I'm just a bit frustrated and looking for some help on how to use Torque for what I need. I guess looking at all the examples scared me a bit. I was afraid I would be stuck doing everything thru scripts.
#13
"State something I said wasn't true. A flame would be a direct attack of your person or statements."
"If you were smart you would..."
"If I were you, I would either be smart and ..."
and in the 'apology'
"You must have really thin skin"
An "oops, my bad" would have done just fine :]
Yes you may be right, he could do well with a 3D rendering engine, his team could write everything themselves and they would be happy with that. But he doesn't need to hear that he isn't smart for asking for help.
06/09/2005 (6:56 am)
Chris,"State something I said wasn't true. A flame would be a direct attack of your person or statements."
"If you were smart you would..."
"If I were you, I would either be smart and ..."
and in the 'apology'
"You must have really thin skin"
An "oops, my bad" would have done just fine :]
Yes you may be right, he could do well with a 3D rendering engine, his team could write everything themselves and they would be happy with that. But he doesn't need to hear that he isn't smart for asking for help.
#14
06/09/2005 (7:03 am)
Thank you all for your help. I will try and see what Torque can do for me. I must admit, I don't like be called, in essence, stupid. hehe. Oh well. Water under the bridge. I'll try the examples you suggested Unsung Zero.
#15
One other thing... If you refresh this page after posting it will repost your last reply... Hence the reason you triple posted.
06/09/2005 (7:07 am)
Jonathan - I never called you stupid, or meant to imply it... I am sure you have thte ability to create what you want to with TGE, but doing it in a way other then what Torque was meant to do is not very wise. If I were you I would read up on the engine flow of TGE... That will give you an idea of how things work, and what to expect when it comes to coding functionality. The resources in aprticular are a very good source. By reading through some of htem you will get an idea of how certain types of solutions are implimented.One other thing... If you refresh this page after posting it will repost your last reply... Hence the reason you triple posted.
#16
What I said is (arguably) probably the smart way to go about things. . . or rather the most efficient way...
Let's just stop nitpicking... It doesnt matter. Water under the bridge as it were.
The point is, if Mr.Morin is to use TGE to accomplish whatever task it is he wants to accomplish, then he may need to reexamine his mindset towards TGE and either adopt it, or find a different engine that suits him better. . . Hard, cold factual info.
06/09/2005 (7:12 am)
Unsung Zero - I was attempting to direct him towards a workflow that would optomize his efficiency and productivity. I won't appologize for that. What I said is (arguably) probably the smart way to go about things. . . or rather the most efficient way...
Let's just stop nitpicking... It doesnt matter. Water under the bridge as it were.
The point is, if Mr.Morin is to use TGE to accomplish whatever task it is he wants to accomplish, then he may need to reexamine his mindset towards TGE and either adopt it, or find a different engine that suits him better. . . Hard, cold factual info.
#17
06/09/2005 (7:14 am)
Agreed Chris. Water under the bridge.
#18
TorqueScript is, at it's most theoretical level, simply a mechanism to easily call c++ functionality. When you want to add new functionality to Torque, here's how it works:
1) Define your requirements, define your performance needs.
2) Take a look at the current class hierarchy of primary inheritible objects (ConObject, SimObject, NetObject, SceneObject, GameBase, Player, etc.) and see if the functionality is either:
--A) already present, just needs some modification,
--B) not present, but an inheritible class exists to provide parent level functionality
--C) so drastically different (not really simulation related, for example), that you'll need to start a new root class. This should almost never happen, but it is possible.
3) Implement your class in accordance with the Torque class standards.
4) Provide scripting hooks if you wish so that scripters can use your class within the scripting language.
Another thing that you will need to keep in mind is that Torque is a very event driven simulation. You do have the primary functionality to have objects polled every simulation tick, but as should be obvious from your experience, event driven processing allows you much greater performance capabillity.
06/09/2005 (10:15 am)
K, now that the water is under the bridge, here's a few insights:TorqueScript is, at it's most theoretical level, simply a mechanism to easily call c++ functionality. When you want to add new functionality to Torque, here's how it works:
1) Define your requirements, define your performance needs.
2) Take a look at the current class hierarchy of primary inheritible objects (ConObject, SimObject, NetObject, SceneObject, GameBase, Player, etc.) and see if the functionality is either:
--A) already present, just needs some modification,
--B) not present, but an inheritible class exists to provide parent level functionality
--C) so drastically different (not really simulation related, for example), that you'll need to start a new root class. This should almost never happen, but it is possible.
3) Implement your class in accordance with the Torque class standards.
4) Provide scripting hooks if you wish so that scripters can use your class within the scripting language.
Another thing that you will need to keep in mind is that Torque is a very event driven simulation. You do have the primary functionality to have objects polled every simulation tick, but as should be obvious from your experience, event driven processing allows you much greater performance capabillity.
Torque Owner Chris Labombard
Premium Preferred
Sorry to break it to you, but you almost HAVE to use scripting in some form or another... Engine mods will change the functionality of the game, but script is where you set the game up.
I highly doubt you are going to get around script.
What exactly are you trying to do ? Sounds like you are trying ot imtegrate torque into your project. Try implimenting your project into Torque, it will be a lot easier on you.
EDIT: If you want to see the flow of the eninge... start looking at the main.cs scripts in the example folder.