• 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
Question by Reefer · Aug 29, 2013 at 12:07 AM · enemyhitblood

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.

Comment

People who like this

0 Show 4
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 getyour411 · Aug 29, 2013 at 12:14 AM 0
Share

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.

avatar image Reefer · Aug 29, 2013 at 12:27 AM 0
Share

So the best way to go would be with changing material to bloody? Or atleast easiest way with rotations and animations?

avatar image getyour411 · Aug 29, 2013 at 12:30 AM 0
Share

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

avatar image Reefer · Aug 29, 2013 at 12:32 AM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

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!

Comment
Reefer

People who like this

1 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 Reefer · Aug 29, 2013 at 01:35 AM 0
Share

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.

avatar image sooncat · Aug 29, 2013 at 01:46 AM 0
Share

1 material is enough. Set the color to White in normal,and set red in hit.

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.

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

19 People are following this question.

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

Related Questions

Hit enemy life 0 Answers

How to make my enemy bleed 1 Answer

DetectSphere - No physics 1 Answer

The name `target' does not exist in the current context 1 Answer

How do I use particles to make blood spurt from an enemy when you shoot it? 1 Answer


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