Single-Player support
by Jay Barnson · in Torque Game Engine · 02/03/2005 (5:28 pm) · 11 replies
I'm working on a single-player game right now in Torque, using some new objects subclassed from ShapeBase. I ran into a somewhat interesting bug in my code that took me a while to figure out - it only appeared when there was a lot happening on the screen at once. What I realized was that it was a synch error between client and server - and the reason it was appearing was because Torque was slowing down the updates due to the amount of 'data' to be passed between client and server.
I am getting worried about the maximum number of objects / updates on the screen. Is there something I'm missing to allow Torque to instantly communicate changes to objects at it's maximum update rate rather than having those updates throttled as they are? Or am I just acting clueless?
I am getting worried about the maximum number of objects / updates on the screen. Is there something I'm missing to allow Torque to instantly communicate changes to objects at it's maximum update rate rather than having those updates throttled as they are? Or am I just acting clueless?
About the author
Jay has been a mainstream and indie game developer for a... uh, long time. His professional start came in 1994 developing titles for the then-unknown and upcoming Sony Playstation. He runs Rampant Games and blogs at Tales of the Rampant Coyote.
#2
And, as Manuel says, you can tweak net params - some are hardcoded, some are set from script prefs. Depends on what you're doing and what your plans are regarding multiplayer.
02/10/2005 (3:16 am)
If you're writing your own net code, make sure it's as efficient as possible - a few bits shaved off here and there can add up to significant savings. You can often cut update sizes in half or better just by tweaking the precisions of what's sent across.And, as Manuel says, you can tweak net params - some are hardcoded, some are set from script prefs. Depends on what you're doing and what your plans are regarding multiplayer.
#3
Nick
02/10/2005 (4:29 am)
It'd be nice if we had some standard tweaking examples for single-layer ONLY games. I've seen somewhere in a thread about how to increase the packet size but I'm sure there are more tweaks that can be done.Nick
#4
02/10/2005 (1:46 pm)
As it happens, one of my current projects is setting up an area on the site where such examples can be posted and shared.
#6
So mainly I'm looking to either bypass the netcode or simply make the 'virtual pipe" as humongous as possible. I'm also doing some server-side simplification of "virtualizing" game objects outside a certain range of the player. They are tracked and recorded, but they don't exist as actual game objects. This is going a little further than I'd get from the basic scopeQueries.
That will probably get things where I need them.
02/12/2005 (2:42 pm)
I don't forsee ANY multiplayer with this project --- while theoretically a multiplayer cooperative mode might be possible, I really don't see it happening.So mainly I'm looking to either bypass the netcode or simply make the 'virtual pipe" as humongous as possible. I'm also doing some server-side simplification of "virtualizing" game objects outside a certain range of the player. They are tracked and recorded, but they don't exist as actual game objects. This is going a little further than I'd get from the basic scopeQueries.
That will probably get things where I need them.
#7
02/12/2005 (7:56 pm)
Well, in that case, make the virtual packet size about a meg, set the update rate to 20 or 30hz, and go to town. :)
#8
And can you tell me where can I find the "update rate"?
Thanks
02/13/2005 (5:00 am)
Ben are you referring to this? $pref::Net::PacketSize = "450";And can you tell me where can I find the "update rate"?
Thanks
#9
From netConnection.cc:156. Those control the packet size and update rate. Unfortunately, I think stock Torque maxes out with a packet size of over a kilobyte or so. It should be possible to raise that limit for local connections with a bit of experimentation. (One approach: try raising it a lot and see where it crashed in a debugger. :)
02/13/2005 (5:48 pm)
Con::addVariable("pref::Net::PacketRateToServer", TypeS32, &gPacketRateToServer);
Con::addVariable("pref::Net::PacketRateToClient", TypeS32, &gPacketRateToClient);
Con::addVariable("pref::Net::PacketSize", TypeS32, &gPacketSize);From netConnection.cc:156. Those control the packet size and update rate. Unfortunately, I think stock Torque maxes out with a packet size of over a kilobyte or so. It should be possible to raise that limit for local connections with a bit of experimentation. (One approach: try raising it a lot and see where it crashed in a debugger. :)
#10
Nick
02/14/2005 (12:14 am)
Thanks Ben! Anything I can do to optimize my single-player game is usefull.Nick
#11
You just wanted me to feel at home, didn't you?
Okay. I don't think I'm going to need to raise it above the 450 limit, but we'll see. So far I've been pretty lazy and sent (almost) EVERYTHING over in the packet update, while I was trying to figure out how server and client were getting out of synch.
Thanks tons, Ben!
02/14/2005 (10:06 am)
Quote: (One approach: try raising it a lot and see where it crashed in a debugger. :)LOL.
You just wanted me to feel at home, didn't you?
Okay. I don't think I'm going to need to raise it above the 450 limit, but we'll see. So far I've been pretty lazy and sent (almost) EVERYTHING over in the packet update, while I was trying to figure out how server and client were getting out of synch.
Thanks tons, Ben!
Associate Manoel Neto
Default Studio Name