- Home /
Blood on weapon.
Hi, I couldnt find any questions about this so:
Let's imagine that you have a game where you can hit enemies with blunt weapons like a club or whatever another blunt weapon. So, now if player hits enemy with an any of these blunt weapons it should get blood on itself.
Is there any clever way to do this? Or is the only way just to check if the collision is with "enemyhead" collision box, do some blood particles and change material of a weapon to bloody, even though this means that you have to do bloody texture for every single weapon in game.
By clever way I mean something like a script that looks where blood particles are hit and then paints some blood texture there. Sorry if this sounds stupid, I'm not so sure yet of how particles work or if you can even do so with Free version or even with Pro.
Tough one - maybe you have an invisible GameObject positioned on the weapon and spawn a brief prefab at that location to simulate gore, but that sounds like it would be tough to pull off visually especially during rotations and animations.
So the best way to go would be with changing material to bloody? Or atleast easiest way with rotations and animations?
Not sure, personally I'd try the invisible GameObject / spawn prefab approach to see if it'll be convincing enough. I'd hate to have to go through all my weapons and have a bloody/not texture
Alright, I might try that out before starting to work with bloody / not bloody textures if someone else can't come up with a better way.
Answer by OP_toss · Aug 29, 2013 at 12:58 AM
I don't like instantiating anything at runtime if I can help it, so here's an alternative solution. Bear in mind it requires some understanding of Shader programming.
Use the alpha of the same weapon texture as a mask for what is "bloody". Then just multiply it by red (optionally an input property) and blend that on top of your texture. This will optimize your shader by reducing texture lookups and memory usage (1 texture much better than 2 textures). It also simplifies and standardizes the "bloody" effect by making it just a mask for a color.
Now you just create 2 materials, one that uses the alpha like I described above, another that doesn't. Swap them when you're hit.
If you want to get fancy, you can just add a float property to your shader that scales the "bloody" effect on and off. Then you can do things like Fade it off and on, or even threshhold your "bloody" alpha mask (this could give the effect of blood expanding or contracting along the weapon).
Shaders are fun :)
Hope this helps!
Now this sounds a much better way from what I understand, but I don't have any clue about shaders. I guess I gotta look up some info about coding shaders.
1 material is enough. Set the color to White in normal,and set red in hit.