Precipitation On Clients Only????
by DALO · in Technical Issues · 09/19/2008 (7:01 am) · 35 replies
Hello,
I have been on a quest to try and figure out a way to have precipitation on multiplayer games where only the client will see there own precipitation. Why? well me thinks that it will first of minimize network traffic and it will increase the dynamics of your levels. I need that option where it will be on only 1 client, where as right now if precipitation is started all clients see it. Well what if your level, for example, has an area where a client is in a burnt forest and there are ashes flying around, and in another part of the level a different client is in a rainy swamp? As soon as you start one precipitation the other client will see it and then you'll have 2 different precipitations mixing......Not Good.
I have attempted to send a list of datablock id's of all the necessary precipitation datablocks to all clients that join and create the precipitation using that specific id that was sent from the server. I had no such luck. Any clients that start the precipitation with the keyword 'new' then the object is created but is not found, the client can not see the precipitation. However, using the exact same method the client that was hosting the game, the server, would create the precipitation object when they enter a certain area and when they do, everyone else would then see that precipitation.......
Any other suggestions, thoughts on how to achieve this???
Thx.
I have been on a quest to try and figure out a way to have precipitation on multiplayer games where only the client will see there own precipitation. Why? well me thinks that it will first of minimize network traffic and it will increase the dynamics of your levels. I need that option where it will be on only 1 client, where as right now if precipitation is started all clients see it. Well what if your level, for example, has an area where a client is in a burnt forest and there are ashes flying around, and in another part of the level a different client is in a rainy swamp? As soon as you start one precipitation the other client will see it and then you'll have 2 different precipitations mixing......Not Good.
I have attempted to send a list of datablock id's of all the necessary precipitation datablocks to all clients that join and create the precipitation using that specific id that was sent from the server. I had no such luck. Any clients that start the precipitation with the keyword 'new' then the object is created but is not found, the client can not see the precipitation. However, using the exact same method the client that was hosting the game, the server, would create the precipitation object when they enter a certain area and when they do, everyone else would then see that precipitation.......
Any other suggestions, thoughts on how to achieve this???
Thx.
#22
10/13/2008 (12:31 am)
Step into isClientObject(), its checking the netMask I referred to before.
#23
(ScopeAlways)
(Ghostable)
(Ghostsable | ScopeAlways)
(0)
(ScopeLocal)
......etc (set in the constructor)
I tried numerous variations and it seemed like nothing changed????
Any ideas why it's never 1 and always 2??
Thx.
10/13/2008 (12:46 am)
It seemed like everytime I stepped through that part it was always 2. I'm not really sure what that code chunk is really doing since it's reffering to bit operations. I then tried setting the netMask to a variety of mask types such as:(ScopeAlways)
(Ghostable)
(Ghostsable | ScopeAlways)
(0)
(ScopeLocal)
......etc (set in the constructor)
I tried numerous variations and it seemed like nothing changed????
Any ideas why it's never 1 and always 2??
Thx.
#24
10/13/2008 (1:09 am)
Which version of the engine are you using?
#25
10/13/2008 (8:16 am)
TGE 1.5.2
#26
......could be an easy $50 bucks for someone..........
@James, thx for your help.
10/16/2008 (2:05 pm)
Well, I give up, I've spent too much time on it and I have other things to get done. I just don't know enough of netMasking, scoping and ghosts to render precip on specific clients, not all clients. So know one at GG want's to help............? I'll pay anyone $50 bucks (via paypal) if you can correctly get this working and send me the code.......could be an easy $50 bucks for someone..........
@James, thx for your help.
#27
good old Edward F. Maurina finally published a book about the inner workings of the torque engine. His eariler book only covered torque script to a very good level which was fine it was what it was written to do. Have not had a chance to read the book myself i recently ordered it as soon as i found out it had come out. But from what i have seen from amazon.com's look inside it the engines networking quite well and has several chapters simply devoted to that.
http://www.garagegames.com/blogs/2311/14494
10/17/2008 (9:16 am)
Wish i knew more about the inner workings of the engine myself at the moment. To be honest you might be better off taking that 50 dollars and getting somthing that will help you in the future as wellgood old Edward F. Maurina finally published a book about the inner workings of the torque engine. His eariler book only covered torque script to a very good level which was fine it was what it was written to do. Have not had a chance to read the book myself i recently ordered it as soon as i found out it had come out. But from what i have seen from amazon.com's look inside it the engines networking quite well and has several chapters simply devoted to that.
http://www.garagegames.com/blogs/2311/14494
#28
After reading most of it, I almost had it working but for some reason the client was looked at as a server object. I trial and error'd many different mask types and no matter how I set the mNetFlags.set when a client created the precip from the client side, when it came to this code line: isClientObject() in the onAdd() function is always returned false even though is was a client that had connected to server, NOT a client that is a server as well.
This is the answer I'm looking for.............like I said, it could be an easy $50 bucks..........
10/17/2008 (9:39 am)
Yeah, I actually have the book, and it's a good book, definitely worth purchasing. One thing that I have found is that there are only a few subjects that it seems he chose to go in depth on, while other subjects just scratched the surface. Someone should make a nice thick mofo Bible for Torque, answering all the questions you could have. After reading most of it, I almost had it working but for some reason the client was looked at as a server object. I trial and error'd many different mask types and no matter how I set the mNetFlags.set when a client created the precip from the client side, when it came to this code line: isClientObject() in the onAdd() function is always returned false even though is was a client that had connected to server, NOT a client that is a server as well.
This is the answer I'm looking for.............like I said, it could be an easy $50 bucks..........
#29
10/18/2008 (8:35 pm)
Why not use trigggers , when the player enters the area they see rain .. if they are not inside the trigger they dont see it , hence one client will see rain while another in a different part of the map wont see it.
#30
10/18/2008 (8:46 pm)
When precip is started, it starts for ALL clients. The big puzzling question is how do you start precip for only 1 client out of....oh let's say 10 people in the game????
#31
The Precipitation class exposes a console function "modifyStorm" on both client and server instances. If you call modifyStorm() on the server instance, it WILL OVERRIDE ALL client instances with the new server setting. BUT if you only call modifyStorm() on the client side.. you can achieve the effect you're looking for.
So, how you you set this up to target individual clients? Easy. First, set up your triggers on the server something like this:
Now add this function to one of the client scripts (say client/scripts/client.cs for example):
You will of course have to change the object names to suit your needs, but that should work. Give it shot! Hopefully no modification will be necessary for 1.5 compatibility.
10/20/2008 (7:36 pm)
It seems there is a really simple solution to this.. Now, I don't have Torque 1.5, but I can tell you this works on 1.3 (and the 1.4 code looks the same in this regard). With any luck it will be no different in 1.5.The Precipitation class exposes a console function "modifyStorm" on both client and server instances. If you call modifyStorm() on the server instance, it WILL OVERRIDE ALL client instances with the new server setting. BUT if you only call modifyStorm() on the client side.. you can achieve the effect you're looking for.
So, how you you set this up to target individual clients? Easy. First, set up your triggers on the server something like this:
function rainOnOff(%client, %onOff)
{
if (!isObject(%client)) return;
// Only the server can identify the Precipitation objects by name.
// Each client will identify their copy of the Precipitation object by a ghost id.
%ghostID = %client.getGhostID([b]SomeRainPrecip[/b]);
%time = 2; // seconds for rain to start/stop
commandToClient(%client, 'ModifyStorm', %ghostID, %onOff, %time);
}
function [b]SomeRainTrigger[/b]::onEnterTrigger(%this,%trigger,%obj)
{
rainOnOff(%obj.client, 1); // 1 for On
}
function [b]SomeRainTrigger[/b]::onLeaveTrigger(%this,%trigger,%obj)
{
rainOnOff(%obj.client, 0); // 0 for Off
}Now add this function to one of the client scripts (say client/scripts/client.cs for example):
function clientCmdModifyStorm(%ghostID, %mod, %time)
{
%conn = GameConnection::getServerConnection();
// Now we use the connection object to find the client Precipitation instance
// that corresponds to the ghost id sent from the server.
%storm = %conn.resolveGhostID(%ghostID);
%storm.modifyStorm(%mod, %time);
}You will of course have to change the object names to suit your needs, but that should work. Give it shot! Hopefully no modification will be necessary for 1.5 compatibility.
#32
Just from having a quick glance at the engine code, it seems that if I were to have 5 precip's going and I call the modifyStorm function and turn them all off, it will still have to perform all the calculations, positioning and whatnot for the precip objects. (I could be totally wrong......?) I do notice some performance difference when 5 precip objects are going just in general, did you ever notice any performance hits when using this method?
(Like I said, I'll have to test it out later tonight, but if knew off hand, that'd be great ;-) )
Thx.
10/21/2008 (8:55 am)
Hey thanks for responding Scott, I didn't even think to look at modifyStorm. Just been focusing on the whole network end of it and trying to scope it only to 1 client. I have been playing with it a bit here and I can't fully test the multiplayer until later but from what I've seen in single player it almost works. When I set the modifyStorm level to zero, there's the odd particle floating around so it's like 98% off. Is there any way to completely shut it off?Just from having a quick glance at the engine code, it seems that if I were to have 5 precip's going and I call the modifyStorm function and turn them all off, it will still have to perform all the calculations, positioning and whatnot for the precip objects. (I could be totally wrong......?) I do notice some performance difference when 5 precip objects are going just in general, did you ever notice any performance hits when using this method?
(Like I said, I'll have to test it out later tonight, but if knew off hand, that'd be great ;-) )
Thx.
#33
I thought that might happen. Reading over the code last night, I suspected there was a flaw in the method that recalculates the particle count. It shouldn't be too difficult to fix, but we should technically take that to a private SDK forum to continue that discussion.
As for performance concerns.. Yes the Precipitation instances are still active and part of the scene, although since modifyStorm() actually changes the particle count (not simply hiding them), the performance penalty should not be too bad. That said though, it should be fairly trivial to add a check for a zero particle count, and temporarily remove the object from the scene altogether. I will look into that.
10/21/2008 (9:53 am)
Quote:there's the odd particle floating around so it's like 98% off. Is there any way to completely shut it off?
I thought that might happen. Reading over the code last night, I suspected there was a flaw in the method that recalculates the particle count. It shouldn't be too difficult to fix, but we should technically take that to a private SDK forum to continue that discussion.
As for performance concerns.. Yes the Precipitation instances are still active and part of the scene, although since modifyStorm() actually changes the particle count (not simply hiding them), the performance penalty should not be too bad. That said though, it should be fairly trivial to add a check for a zero particle count, and temporarily remove the object from the scene altogether. I will look into that.
#34
I posted a fix there for the function that recalculates the particle count. The particle list can now be completely cleared by calling modifyStorm(0,x). With no particles to process or render, the overhead of leaving the Precipitation class in the scene should be minimal.
10/21/2008 (5:04 pm)
Followup: www.garagegames.com/mg/forums/result.thread.php?qt=80232I posted a fix there for the function that recalculates the particle count. The particle list can now be completely cleared by calling modifyStorm(0,x). With no particles to process or render, the overhead of leaving the Precipitation class in the scene should be minimal.
#35
10/22/2008 (9:24 pm)
Brilliant..........I can't believe that's all it took was a simple call to modifyStorm.........drop me an email with some info to claim your prize :-)
Torque 3D Owner DALO
How and what variable would I set to make it know that all precip objects created are clientObjects and not server objects? Is there a mask I need to add to the constructor indicating client object?
Thx again.