mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
Merge pull request #632 from eightyeight/better-explosion-example
Added a better example of using Explosion in a client/server fashion
This commit is contained in:
commit
47dbce1499
|
|
@ -106,18 +106,31 @@ ConsoleDocClass( Explosion,
|
|||
" lightEndBrightness = 0.0;\n"
|
||||
" lightNormalOffset = 2.0;\n"
|
||||
"};\n\n"
|
||||
"function createExplosion()\n"
|
||||
"function ServerPlayExplosion(%position, %datablock)\n"
|
||||
"{\n"
|
||||
" // Create a new explosion - it will explode automatically\n"
|
||||
" %pos = \"0 0 100\";\n"
|
||||
" %obj = new Explosion()\n"
|
||||
" // Play the given explosion on every client.\n"
|
||||
" // The explosion will be transmitted as an event, not attached to any object.\n"
|
||||
" for(%idx = 0; %idx < ClientGroup.getCount(); %idx++)\n"
|
||||
" {\n"
|
||||
" position = %pos;\n"
|
||||
" dataBlock = GrenadeLauncherExplosion;\n"
|
||||
" };\n"
|
||||
" %client = ClientGroup.getObject(%idx);\n"
|
||||
" commandToClient(%client, 'PlayExplosion', %position, %datablock.getId());\n"
|
||||
" }\n"
|
||||
"}\n\n"
|
||||
"function clientCmdPlayExplosion(%position, %effectDataBlock)\n"
|
||||
"{\n"
|
||||
" // Play an explosion sent by the server. Make sure this function is defined\n"
|
||||
" // on the client.\n"
|
||||
" if (isObject(%effectDataBlock))\n"
|
||||
" {\n"
|
||||
" new Explosion()\n"
|
||||
" {\n"
|
||||
" position = %position;\n"
|
||||
" dataBlock = %effectDataBlock;\n"
|
||||
" };\n"
|
||||
" }\n"
|
||||
"}\n\n"
|
||||
"// schedule an explosion\n"
|
||||
"schedule(1000, 0, createExplosion);\n"
|
||||
"schedule(1000, 0, ServerPlayExplosion, \"0 0 0\", GrenadeLauncherExplosion);\n"
|
||||
"@endtsexample"
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue