Bullet Hole Decals
by Tim Heldna · 12/18/2005 (6:44 pm) · 32 comments
Bullet Hole Decals
I've decided to post this as a resource because I believe most people don't know that this function exists for projectiles.
Here's how to set it up:
N.B. I will be using the standard crossbow.cs script as a reference
In your weapon file go to the datablock ProjectileData(CrossbowProjectile) section and add this to the bottom of that datablock before the last };
Then directly above this datablock set up your decal data which should look something like this:
That's it, now when your projectile hits something it will leave a decal. You can adjust how long this decal lasts, max number of decals, and whether decals are enabled or disabled by going into starter.fps\client\prefs.cs and adjusting...
$pref::Decal::decalTimeout = "5000";
$pref::Decal::maxNumDecals = "256";
$pref::decalsOn = "1";
...accordingly.
Hope this is useful.
P.S. Make sure you're texture paths within the datablock DecalData are valid.
EDIT July 31st 2006 - Your weapon's projectile must have an explosion specified for decals to work!
E.g.
I've decided to post this as a resource because I believe most people don't know that this function exists for projectiles.
Here's how to set it up:
N.B. I will be using the standard crossbow.cs script as a reference
In your weapon file go to the datablock ProjectileData(CrossbowProjectile) section and add this to the bottom of that datablock before the last };
decals[0] = CrossbowDecal1; decals[1] = CrossbowDecal2; decals[2] = CrossbowDecal3; decals[3] = CrossbowDecal4; decals[4] = CrossbowDecal5; decals[5] = CrossbowDecal6;The whole thing should look like this:
datablock ProjectileData(CrossbowProjectile)
{
projectileShapeName = "~/data/shapes/crossbow/projectile.dts";
directDamage = 20;
radiusDamage = 20;
damageRadius = 1.5;
areaImpulse = 200;
explosion = CrossbowExplosion;
waterExplosion = CrossbowWaterExplosion;
particleEmitter = CrossbowBoltEmitter;
particleWaterEmitter= CrossbowBoltBubbleEmitter;
splash = CrossbowSplash;
muzzleVelocity = 100;
velInheritFactor = 0.3;
armingDelay = 0;
lifetime = 5000;
fadeDelay = 5000;
bounceElasticity = 0;
bounceFriction = 0;
isBallistic = false;
gravityMod = 0.80;
hasLight = true;
lightRadius = 4;
lightColor = "0.5 0.5 0.25";
hasWaterLight = true;
waterLightColor = "0 0.5 0.5";
[b]//Decal Data Start[/b]
decals[0] = CrossbowDecal1;
decals[1] = CrossbowDecal2;
decals[2] = CrossbowDecal3;
decals[3] = CrossbowDecal4;
decals[4] = CrossbowDecal5;
decals[5] = CrossbowDecal6;
[b]//Decal Data End[/b]
};Then directly above this datablock set up your decal data which should look something like this:
datablock DecalData(CrossbowDecal1)
{
sizeX = 0.05;
sizeY = 0.05;
textureName = "~/data/shapes/chaingun/textures/bullethole1";
};
datablock DecalData(CrossbowDecal2 : CrossbowDecal1)
{
textureName = "~/data/shapes/chaingun/textures/bullethole2";
};
datablock DecalData(CrossbowDecal3 : CrossbowDecal1)
{
textureName = "~/data/shapes/chaingun/textures/bullethole3";
};
datablock DecalData(CrossbowDecal4 : CrossbowDecal1)
{
textureName = "~/data/shapes/chaingun/textures/bullethole4";
};
datablock DecalData(CrossbowDecal5 : CrossbowDecal1)
{
textureName = "~/data/shapes/chaingun/textures/bullethole5";
};
datablock DecalData(CrossbowDecal6 : CrossbowDecal1)
{
textureName = "~/data/shapes/chaingun/textures/bullethole6";
};That's it, now when your projectile hits something it will leave a decal. You can adjust how long this decal lasts, max number of decals, and whether decals are enabled or disabled by going into starter.fps\client\prefs.cs and adjusting...
$pref::Decal::decalTimeout = "5000";
$pref::Decal::maxNumDecals = "256";
$pref::decalsOn = "1";
...accordingly.
Hope this is useful.
P.S. Make sure you're texture paths within the datablock DecalData are valid.
EDIT July 31st 2006 - Your weapon's projectile must have an explosion specified for decals to work!
E.g.
explosion = CrossbowExplosion;
About the author
Recent Blogs
• BCS Street props• Character Pack - Vince
• Recent Artwork
• Progress of our Weapon Pack
• Digital Speedometer
#22
We are releasing a free fps game based on the Australian Army, lots of cool stuff in that. Hope to release it around mid this year. The idea being if anyone likes any particular feature within the game we'll post a resource on it.
03/07/2006 (8:45 am)
You'll have to wait & see James ; )We are releasing a free fps game based on the Australian Army, lots of cool stuff in that. Hope to release it around mid this year. The idea being if anyone likes any particular feature within the game we'll post a resource on it.
#23
04/19/2006 (12:22 am)
the resource is very usefull for me, but the texture is disappeared after few seconds, but i need it fixed on the interior, what i want to do.
#24
07/29/2006 (3:08 pm)
EXCELLENT resource! Straightforward and really useful thanks!!
#25
Can $pref::Decal::decalTimeout = "NEVER?";?
I guess I could use $pref::Decal::decalTimeout = "50000000000000";
but there has to be a better way.
Thanks!
03/10/2007 (1:09 am)
Same question as Roshan...Can $pref::Decal::decalTimeout = "NEVER?";?
I guess I could use $pref::Decal::decalTimeout = "50000000000000";
but there has to be a better way.
Thanks!
#26
03/26/2007 (10:33 am)
Don't work in the 1.5 version
#27
03/31/2007 (7:16 pm)
Quote:It should, though I don't own 1.5 and never will so I can't say for sure. I know decals don't work in TGEA out of the box, maybe GG broke them in 1.5 of TGE too, I guess they have an aversion to decals.
Don't work in the 1.5 version
#28
05/31/2007 (8:44 pm)
Worked for me in 1.5
#29
06/01/2007 (5:48 am)
Thanks for the heads up. I thought it was odd for this to not work in 1.5 seeing how it doesn't rely on any major engine code.
#30
However with the stock code it would only work on the terrain and not on objects.
If you change:
if(collideType & (TerrainObjectType | InteriorObjectType))
to
if (collideType & (TerrainObjectType | InteriorObjectType | StaticObjectType | StaticRenderedObjectType))
in projectile.cc in the Projectile::explode function (around line 731) would enable you to leave bullet holes on objects.
07/09/2007 (1:07 pm)
Actually it works fine in 1.5.2 for me.However with the stock code it would only work on the terrain and not on objects.
If you change:
if(collideType & (TerrainObjectType | InteriorObjectType))
to
if (collideType & (TerrainObjectType | InteriorObjectType | StaticObjectType | StaticRenderedObjectType))
in projectile.cc in the Projectile::explode function (around line 731) would enable you to leave bullet holes on objects.
#31
07/11/2007 (7:35 am)
The reason decals are disabled by default on DTS objects is that they use a bounding box for collision - Torque's decal manager does NOT support decals applied to an arbitrary surface. This means that in most cases, the decal(s) will be hovering in mid air, pending how tight your bounding box is.
#32
07/24/2007 (4:22 pm)
Any ideas on how to get these decals to work with RigidShape Class. I tried vehicleObjectType since thats where the class is derived from, but no dice. 
Torque Owner James Brady