Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by 45325426243 · Feb 20, 2017 at 09:40 AM · 2d-platformertexturesoffscreen

Blood covering ground in 2D platformer

Hello,

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: http://jsfiddle.net/0pg0LpL1/4/embedded/result/ , animated gif: http://imgur.com/oTeDydV) alt text

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:

  • Blood particle traces: http://imgur.com/a/0iIeQ

  • Ground mask: http://imgur.com/a/YKvCK

  • Masked traces (what I call blood texture): http://imgur.com/a/M8z2v

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.

screen-shot-2017-02-18-at-234345.png (18.0 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by koslovdenis · Jun 15, 2017 at 09:53 AM

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. :/

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image 45325426243 · Jun 19, 2017 at 10:28 PM 0
Share

Hi @koslovdenis. Unfortunately no, I did not find any good solution. Let me know if you manage to produce this kind of effect.

avatar image koslovdenis 45325426243 · Aug 19, 2017 at 12:48 PM 0
Share

Hi 45325426243, I finally got the way how to make it more or less like that. I used particles and I was wrong that it doesn't have physics though - it does, you just have to enable it in particle editor. So it can stick to walls and at other colliders. You can set up the lifetime of the blood and the gravity scale. It worked for me just the best ) I've got a nice horror slashy effect. I am attaching the tutorial that helped me to make a nice start with that. Good luck with your project ;)

https://www.youtube.com/watch?v=ge9X$$anonymous$$r$$anonymous$$x8m8

avatar image
0

Answer by E_101 · Jan 18, 2018 at 06:45 AM

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[i].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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Ideal resolutions for 2D platformer Art Assets (to make multi-res support easier)? 2 Answers

Steam Overlay provoking flashing textures 1 Answer

Load Terrain Alpha Maps and Edit them 0 Answers

Select UV map 0 Answers

How can I achieve a gradual cross-fade of terrain and speedtree textures/materials for season variation? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges