Blood covering ground in 2D platformer


I have just started my adventure with Unity so my question may seem silly to experienced users but anyway I’ll give it a try. If you could just give me couple of keywords I could search for in order to solve my problem I would be very grateful.

As a sample project I wanted to create 2D pixel platformer, something like Contra. All went well up to the moment when I wanted to add some blood dripping from my enemies. I got stuck on generating the blood particles and simulating them painting over the ground. The effect I want to achieve looks like this: (live example: , animated gif: Imgur: The magic of the Internet) 88339-screen-shot-2017-02-18-at-234345.png

I am wondering what is the best approach to achieve such effect. I thought about generating the texture of blood stains on the fly and placing it before camera. It would look like this: scene < blood texture < camera. The blood texture would be generated from lines drawn by “flying” blood particles masked by the ground/platforms texture:

What is the best approach to achieve such effect? I know that generating texture with Texture2D.SetPixels on each frame is not optimal. I also see challenge in having a blood texture large enough to span over entire level to keep memory of all the blood spilled. Also the solution with one blood texture will not work if I wanted to have moving platforms that should also be painted.

Thanks in advance for any suggestions.

Did you manage to solve it? I’ve got the same issue, and I am now thinking about how to realize the same effect in my 2D platformer. I was thinking about 2D physics, creating little objects just the same way as particles splash out. But I can’t imagine how that’s supposed to work yet. IT’s a pity particles in Unity doesn’t have physics. :confused:

Hello, I am a novice code writer and am new to Unity but I recently created some code that might be able to help. Also, I have only tested this method on flat horizontal surfaces and it may not work exactly to individual specifications.

After creating your particle system, adding this code to a New Script (C#), and a new sprite for the blood stains you want to create on particle impact; select the sprite under the “Sprite Blood Stain” game object selector.

   using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class BloodStain : MonoBehaviour {
    	public ParticleSystem part;
    	public List<ParticleCollisionEvent> collisionEvents;
    	public GameObject spriteBloodStain;
    	// Use this for initialization
    	void Start () {
    		part = GetComponent<ParticleSystem>();
    		collisionEvents = new List<ParticleCollisionEvent> ();
    	// Update is called once per frame
    	void OnParticleCollision(GameObject other) {
    		int i = 0;
    		int numCollisionEvents = part.GetCollisionEvents(other, collisionEvents);
    		print (numCollisionEvents);
    		//Collision detection of particles on surface, returns location
    		Vector3 locOfParticleCollision = collisionEvents*.intersection;*

_ //(SpriteBeingUsed), (LocationCoordinatesToSpawnSpriteAt), (RotationData)_

  •  Instantiate (spriteBloodStain, locOfParticleCollision, Quaternion.identity);*
  • }*
    There is certainly a better way to do this, however hopefully this has solved other’s issues regarding the same question.