Server Side Explosions
by Alex Scarborough · 01/31/2007 (2:43 pm) · 8 comments
Download Code File
So, this has been sitting in my inbox waiting to be resourcified for about ten months. Oops?
In stock Torque, attempting to create an explosion on the server is generally Not Good, and can lead to odd behaviour or crashing due to how explosions are networked. This resource adds a NetEvent which transmits all information necessary to create an explosion from the server to a client, allowing you to create explosions on the server painlessly.
NOTE: Because I am horribly lazy about these kinds of things, the NetEvent is sent to ALL clients, instead of being properly scoped like it should be. So, while this code is quite suitable for creating an explosion now and then, I certainly wouldn't be flooding the scene with explosions.
Special thanks to Thomas "Man of Ice" Lund, who took my original code (written as an example of how to create a NetEvent) and packaged it up to be a standalone addition to Torque.
So, this has been sitting in my inbox waiting to be resourcified for about ten months. Oops?
In stock Torque, attempting to create an explosion on the server is generally Not Good, and can lead to odd behaviour or crashing due to how explosions are networked. This resource adds a NetEvent which transmits all information necessary to create an explosion from the server to a client, allowing you to create explosions on the server painlessly.
NOTE: Because I am horribly lazy about these kinds of things, the NetEvent is sent to ALL clients, instead of being properly scoped like it should be. So, while this code is quite suitable for creating an explosion now and then, I certainly wouldn't be flooding the scene with explosions.
Special thanks to Thomas "Man of Ice" Lund, who took my original code (written as an example of how to create a NetEvent) and packaged it up to be a standalone addition to Torque.
About the author
#2
02/10/2007 (5:14 am)
Why the use of a NetEvent when you could just make it a ghostable object, like how projectiles work? Not saying this is bad or anything, just asking if there was a specific reason.
#3
I used this resource to make my explosion a NetEvent (as i couln't see it at the client side) and i face a problem.
When i press 'Launch Mission' the 'loading datablocks' bar stops at the half way and i have a 'fatal error' that says: 'Out of bounds value' (fatal error torque/engine/core/bitstream.h @257) and then i have to end the game.
Does anyone know what's going on? Are there any others with the same problem?
Please help!
Thanks.
09/08/2007 (1:19 am)
Hello everyone!I used this resource to make my explosion a NetEvent (as i couln't see it at the client side) and i face a problem.
When i press 'Launch Mission' the 'loading datablocks' bar stops at the half way and i have a 'fatal error' that says: 'Out of bounds value' (fatal error torque/engine/core/bitstream.h @257) and then i have to end the game.
Does anyone know what's going on? Are there any others with the same problem?
Please help!
Thanks.
#4
I am not seeing the explosions like I used to when I was simply spawning them on the server in script the old fashioned way which did not spawn them on the clients. But at least on the server, they do not appear as nice or do not appear at all.
%pos = %obj.targetObject.getTransform();
//%explosion = new explosion()
//{
// dataBlock = "HammerExplosionSoft";
// position = %pos;
//};
//MissionCleanup.add(%explosion);
spawnExplosion(%pos, %pos, 0, HammerExplosionSoft);
//
How do you figure out what the normal should be? perhaps this is the problem. I noticed a lack of particles which makes me think I got my nromal wrong.
Thanks!
RB
12/16/2007 (1:51 am)
Thanks for the resource. I have a question or maybe two.I am not seeing the explosions like I used to when I was simply spawning them on the server in script the old fashioned way which did not spawn them on the clients. But at least on the server, they do not appear as nice or do not appear at all.
%pos = %obj.targetObject.getTransform();
//%explosion = new explosion()
//{
// dataBlock = "HammerExplosionSoft";
// position = %pos;
//};
//MissionCleanup.add(%explosion);
spawnExplosion(%pos, %pos, 0, HammerExplosionSoft);
//
How do you figure out what the normal should be? perhaps this is the problem. I noticed a lack of particles which makes me think I got my nromal wrong.
Thanks!
RB
#5
03/10/2008 (2:25 pm)
Robert, did you ever figure out how to get the Normal?
#6
03/13/2008 (7:03 am)
James, I used "0 0 1" and they look AOK now.
#7
10/25/2009 (4:34 am)
how to use this resources in TGE 1.5, pls?
#8
10/26/2009 (12:20 pm)
I got it. 
Torque Owner Thomas \"Man of Ice\" Lund
A few small "improvements" to the explosionNetEvent.cc
In the contructor add this:
Also had a crash in the pack method. So I added this check:
void ExplosionNetEvent::pack(NetConnection *conn, BitStream *bstream) { if (!dataBlock) { return; }Besides that it works, and I still use it for various things.
If anyone could improve it with proper scoping, then that would be super nice