Particle explosion do not work at client-side !!
by BLACKHOUND · in Torque Game Engine · 10/16/2002 (11:17 am) · 48 replies
hello i need some help
my explosion show only at server-side, why ??
----------------
Code :
function SmokeIt()
{
...
%p = new explosion() {
dataBlock = "SpellExplosion";
position = "526.874 86.8943 145.435"; //%finalPos;
};
MissionCleanup.add(%p);
return %p;
}
-----------------
what is the problem ?
thx
Derek
my explosion show only at server-side, why ??
----------------
Code :
function SmokeIt()
{
...
%p = new explosion() {
dataBlock = "SpellExplosion";
position = "526.874 86.8943 145.435"; //%finalPos;
};
MissionCleanup.add(%p);
return %p;
}
-----------------
what is the problem ?
thx
Derek
About the author
#22
11/19/2005 (12:17 am)
*bump*
#23
In other words, explosions in and of themselves are not networked events/objects. You can easily implement an ExplosionEvent if you like, but it is not stock in TGE 1.4 as far as I am aware.
11/19/2005 (2:47 pm)
TGE 1.4 does not allow you to spawn explosions themselves directly in script. The underlying technology for this functionality has not changed--it requires a projectile (which is networked) to have a collision, which then causes both the server and the client to spawn the explosion itself.In other words, explosions in and of themselves are not networked events/objects. You can easily implement an ExplosionEvent if you like, but it is not stock in TGE 1.4 as far as I am aware.
#24
11/19/2005 (11:10 pm)
Thanks for the reply Stephen!
#25
How would one go about doing things such as having different explosions for different objects then? For example if you wanted to create sparks for interiors, dust for dirt and blood for players?
12/31/2005 (3:44 am)
I'm not sure if I am understanding that correctly, figured I'd ask. So basically the problem is you can no longer spawn your explosion in script, but you can use an Explosion = in the datablock for the projectile?How would one go about doing things such as having different explosions for different objects then? For example if you wanted to create sparks for interiors, dust for dirt and blood for players?
#26
You can still spawn a projectile which when it explodes it is network aware so all clients will see it.
So you can spawn a projectile in the on collision. Below is a resource.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2884
12/31/2005 (8:26 am)
@ J.C. Smith the issue is creating explosions like this%exp = new Explosion()
{
// Add relevant stuff
}You can still spawn a projectile which when it explodes it is network aware so all clients will see it.
So you can spawn a projectile in the on collision. Below is a resource.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2884
#27
Tried to do some searching and behold! Here is what Stephen Zepp talks about:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8135
03/20/2006 (9:09 am)
I'm running into the same problem as everyone else - spawning explosions on the server without projectiles.Tried to do some searching and behold! Here is what Stephen Zepp talks about:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8135
#28
03/20/2006 (4:06 pm)
Oi yeah, that's a great resource Thomas, I just plunked that in and added a console function to call it from script, so I can drop in explosions wherever I want. Does anyone know what the overhead of using netEvents is versus netObjects? I just worry since doing this doesn't seem to be scoped and is sent to all the clients. I was thinking of maybe using the method to spawn particles along a path as well so I could have full effects for raycast based weapons with no netObjects involved at all. I looked at the docs and it talks about mGuranteeType, but I'm not well versed enough in C++ to understand how I'm supposed to be setting that...
#29
I also just dumped it into a class by itself and added a console function. Using TSE, but I didnt have time to test it.
Did you just put the explosion datablock in the data dir and point both client and server to that?
03/21/2006 (2:16 pm)
Hey PaulI also just dumped it into a class by itself and added a console function. Using TSE, but I didnt have time to test it.
Did you just put the explosion datablock in the data dir and point both client and server to that?
#30
03/21/2006 (7:47 pm)
I just passed in the name of a defined explosion datablock and looked it up in the function? Ummm... I did this?ConsoleFunction(spawnExplosion, void, 5, 5, "(datablock, position, normal, collision)")
{
ExplosionData* data;
Point3F p(0,0,0);
Point3F n(0,0,0);
SceneObject* col;
Sim::findObject(argv[1],data);
dSscanf(argv[2],"%g %g %g",&p.x,&p.y,&p.z);
dSscanf(argv[3],"%g %g %g",&n.x,&n.y,&n.z);
Sim::findObject(argv[4],col);
SimGroup* pClientGroup = Sim::getClientGroup();
for (SimGroup::iterator itr = pClientGroup->begin(); itr != pClientGroup->end(); itr++)
{
NetConnection* nc = static_cast<NetConnection*>(*itr);
ExplosionMessageEvent* pEvent = new ExplosionMessageEvent;
pEvent->pos = p;
pEvent->normal = n;
pEvent->objectType = col->getType();;
pEvent->dataBlock = data;
nc->postNetEvent(pEvent);
}
}
#31
@Paul: You could probably do an area search and only send the netEvent to clients within the specified area. That'd cut down on bandwidth overhead, at some computational cost. The main benefit to using a netEvent is that it doesn't have to keep track of scoping and ghosting and the like. netEvents are most useful for fast single fire type events, such as an explosion or lighting strike. If you need something more persistent then a netObject is probably the way to go.
03/21/2006 (9:07 pm)
First, I'm glad people are getting some use out of that old resource.@Paul: You could probably do an area search and only send the netEvent to clients within the specified area. That'd cut down on bandwidth overhead, at some computational cost. The main benefit to using a netEvent is that it doesn't have to keep track of scoping and ghosting and the like. netEvents are most useful for fast single fire type events, such as an explosion or lighting strike. If you need something more persistent then a netObject is probably the way to go.
#32
03/21/2006 (10:48 pm)
Well yes, I just intend to use it for single instance effects, but they're since they're only effects and there may be a lot of them, I was just wondering if I add "mGuaranteeType = Unguaranteed;" if that would help, since it's not _imparitive_ the effect show up.
#33
03/21/2006 (10:57 pm)
That would help, yes.
#34
I would think that you need the datablocks fully copied on the client - how else should it know what particles to display etc. But maybe I'm mistaken.
I did some tests last night and got everything running, but I copied the explosion data onto the client side.
In the TSE version I have, I also had to hack up the particleEmitter code. The deleteWhenEmpty() method deleted the explosion before it was displayed on the client. Inserting a "if isClientObject() return;" made it show.
The TSE checkout is rather old, so maybe its a fixed bug, but we are waiting to update TSE until next codedrop.
Alex - good idea with the radius search! WIll have to implement that one. Would you be interested to update your resource with a fully implemented class? I would be very happy to send you what I did.
03/22/2006 (2:22 am)
Paul - did you try that in multiplayer setting?I would think that you need the datablocks fully copied on the client - how else should it know what particles to display etc. But maybe I'm mistaken.
I did some tests last night and got everything running, but I copied the explosion data onto the client side.
In the TSE version I have, I also had to hack up the particleEmitter code. The deleteWhenEmpty() method deleted the explosion before it was displayed on the client. Inserting a "if isClientObject() return;" made it show.
The TSE checkout is rather old, so maybe its a fixed bug, but we are waiting to update TSE until next codedrop.
Alex - good idea with the radius search! WIll have to implement that one. Would you be interested to update your resource with a fully implemented class? I would be very happy to send you what I did.
#35
03/22/2006 (3:04 am)
1.4 just crashes when I try to run a dedicated server, but the explosion datablocks are defined in the server scripts, so I don't see why they wouldn't be copied to all the clients. A radius search within the near the max allowed client view distance could help scoping a little (though I'm not sure if just doing a distance check when you go through the clients would be faster).
#36
03/22/2006 (4:20 am)
I'll do some testing tonight and let you know about server and/or client side. What I've found is that everything works really nicely when not running dedicated server, but nothing is displayed on the client when running in a dedicated server setup (sound still plays).
#37
Are you sure? If you setup a non-dedicated server, other clients (except the local client) should not see the explosion, in standard TGE. With this change, it should be the same for both of them, so I can't see why it wouldn't work on a dedicated server with the resource above, implemented.
03/22/2006 (5:13 am)
ThomasAre you sure? If you setup a non-dedicated server, other clients (except the local client) should not see the explosion, in standard TGE. With this change, it should be the same for both of them, so I can't see why it wouldn't work on a dedicated server with the resource above, implemented.
#38
Yes - you are right. What I mean by a non-dedicated setup is only playing it "single player" locally. I was not clear on that point. Everyone else connected would not see it at all, no matter what.
Now with the NetEvent resource, it seems like everyone sees it. I did have to hack the emitter class though in TSE to even get this working.
-----
Yeah - its me making mistakes all right. Datablocks are naturally send to client and do not have to be added there. Dumb me....
03/22/2006 (6:05 am)
@StefanYes - you are right. What I mean by a non-dedicated setup is only playing it "single player" locally. I was not clear on that point. Everyone else connected would not see it at all, no matter what.
Now with the NetEvent resource, it seems like everyone sees it. I did have to hack the emitter class though in TSE to even get this working.
-----
Yeah - its me making mistakes all right. Datablocks are naturally send to client and do not have to be added there. Dumb me....
#39
03/22/2006 (7:49 am)
@Thomas: Sure, I'm game for making this a new class and tidying it up a little. Just keep in mind that it won't quite be my top priority for a little while. You can send your code to the email address in my profile. Chances are I would be able to get started by sometime next week.
#40
Cheers
08/21/2006 (4:27 am)
Is there any news on this class as it would be really helpful for some of the stuff we are working on...Cheers
Torque 3D Owner Michael Cozzolino
Big Monk Games