Game Development Community

Create a successful bullet hit bleeding.

by Szzg007 · in Torque 3D Professional · 01/05/2012 (7:53 am) · 43 replies

First one..I need thanks for Frank carney and Michael Hall help me.here.
www.garagegames.com/community/forums/viewthread/129268

make new a Particle..

datablock ParticleData(bloodBulletDirtSpray)
{
   textureName          = "art/shapes/particles/FXpack1/dirt";
   dragCoefficient      = "0.667";
   gravityCoefficient   = "0";
   lifetimeMS           = "250";
   lifetimeVarianceMS   = "0";
   spinRandomMin = -120.0;
   spinRandomMax =  120.0;
   useInvAlpha   = true;
   
   colors[0]     = "0.590551 0 0.00787402 1";
   colors[1]     = "0.992126 0 0.015748 1";
   colors[2]     = "0.322835 0 0.00787402 0.291339";

   sizes[0]      = "0.299091";
   sizes[1]      = "0.799609";
   sizes[2]      = "1.19941";

   times[0]      = 0.0;
   times[1]      = "0.494118";
   times[2]      = 1.0;
   animTexName = "art/shapes/particles/FXpack1/dirt";
   
};
datablock ParticleEmitterData(bloodBulletDirtSprayEmitter)
{
   ejectionPeriodMS = "5";
   periodVarianceMS = "0";
   ejectionVelocity = "5";
   velocityVariance = "5";
   thetaMin         = "0";
   thetaMax         = "360";
   particles = "bloodBulletDirtSpray";
   gravityCoefficient = "3.99756";
   lifetimeMS = "10";
   lifetimeVarianceMS = "0";
   spinRandomMin = "-140";
   spinRandomMax = "140";
   useInvAlpha = "1";
   blendStyle = "NORMAL";

};

and add New decaldata
datablock DecalData(bloodDecalData)
{
   Material = "YoubloodMaterial";
....
};
Find game/scripts/server/player.cs
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
//add effectFX for here...
//do decals
   %Decalposition = VectorAdd(getRandom(-1, 1) SPC getRandom(-1, 1) SPC "0", %obj.getPosition()); 
   %normal = "0.0 0.0 1.0";
   %decalObj = decalManagerAddDecal(%Decalposition, %normal, getRandom(360), getRandom(2), bloodDecalData, false);
   //do decals
   %particles = new ParticleEmitterNode() 
   {
      position = %position;
      rotation = "1 0 0 0";
      scale = "1 1 1";
      dataBlock = "bloodNodeData";
      emitter = "bloodBulletDirtSprayEmitter";
      velocity = "1";
   };
   MissionCleanup.add(%particles.schedule(1000, "delete"));
   
//..... other code...
Show is here..
i461.photobucket.com/albums/qq338/szzg007/screenshot_001-00002.png
#21
06/04/2012 (2:26 pm)
Yep just tried it multiplayer, the decals don't appear on the client at all.

What I'd like though is a way of tying the emitter to the player so the player can bleed while moving. Is there an easy way to do that?
#22
06/04/2012 (2:35 pm)
BigDaz, try mounting the emitter on the player.
#23
06/04/2012 (3:24 pm)
Can I do that in the shape editor? It has options for models or pictures but not emitters.
#24
06/04/2012 (3:41 pm)
Nope. You'll have to script it.
#25
06/21/2012 (11:12 am)
tried this with 15 vs 15 AI, worked great for a while then killed the game. There must be a ceiling limit, or it's just not clearing down the particles through mission cleanup.
#26
10/11/2012 (3:32 pm)
Great as ever, best blood Ive seen for Torque3D!!
#27
05/16/2013 (3:57 pm)
I put in all the scripts and everything loads fine, however, no blood appears when I shoot a zombie or a player.
#28
05/16/2013 (4:36 pm)
did you do #17 on the first page by Steve Acaster? sounds like you haven't got a blood splat decal
#29
05/17/2013 (6:48 am)
Yup. When I shoot a character, the standard dust appears, still, and no decals.
#30
07/10/2013 (11:36 pm)
Thanks! Still a good recource!

Has anyone got the solution for
MissionCleanup.add(%particles.schedule(1000, "delete"));
yet? It's like CSMP said; in combination with AI it can crash the engine in strange ways. Most of the times generating errors like trying to delete non-existing objects. Commenting out clears the crashes but creates another problem, obviously.
#31
07/10/2013 (11:56 pm)
untested but instead of
MissionCleanup.add(%particles.schedule(1000, "delete"));

try

MissionCleanup.add(%particles);
%particles.schedule(1000, "delete");
#32
07/11/2013 (12:12 am)
Hi @Jules, I'm testing it now... no errors, no crashes so far! Looking good! Thanks a lot!
#33
07/11/2013 (1:03 am)
After more testing some crashing still occurs. Less frequent though! No errors in the log to be seen.
#34
07/11/2013 (1:18 am)
@Nils - experiment with increasing and decreasing the time (1000) and see if this makes a difference. If not I'll have a look.
#35
07/11/2013 (1:26 am)
also you may want to increase

$pref::Net::PacketRateToClient = "10";

to something higher, as it may be overflowing packets and can't keep up. This may have an impact online though, but these days people have faster connections so you can up it a bit.

I have prefs.cs set to:
$pref::Net::PacketRateToClient = "32";
$pref::Net::PacketRateToServer = "32";
$pref::Net::PacketSize = "450";
#36
07/11/2013 (1:59 am)
Thanks @Jules!

Increased the time to 5000; still crashing or a pretty big drop in FPS.

Already working with those prefs (packet size even bigger) Making a single player adventure.
#37
07/11/2013 (2:03 am)
yeah, probably a bit daft of me to suggest increasing the time.. lack of sleep :) increasing it, would make it work harder to cleanup all those objects. I'm wondering if calling the delete before the mission cleanup may help, not sure.. there is a clash/conflict somewhere.
#38
07/11/2013 (2:11 am)
What I did on one of my game tests was to create a function call on the timer, in this function call would pass the id of the particle to it and set it to %particle.visible = false; (to hide it) then record the id of the particle in an array, with a scheduled event on a server to do a batch for loop on the delete. Down side to this is if you have lots of players, then you have lots of objects.

I'll see what I can come up with as I'm also using this in my game.
#39
07/11/2013 (2:27 am)
This may be the issue and a possible fix, since TGEA days.
Particles

edit...
Maybe add in:

new SimGroup( ClientMissionCleanup );

in your mission file and see if this is the issue.

Backup your mission file first tho
#40
07/11/2013 (4:31 am)
mmm... already creating that SimGroup with clientStartMission()
Can't redeclare another one.

Could a bunch of predefined particle emitters work; transform and activate where and when needed? This way you can keep it controlled?

Note; Like one blood emitter mounted for each player