Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Hathakas · Jan 14, 2015 at 01:24 AM · shaderspritedamage

How do I make my Sprite look Cracked

Hello,

I can't seem to find a soloution online, I expected to find a lot more people asking this question.

Basically, I want an object to show a crack overlay or something (I'm assuming using shaders) when it's health decreases. Kinda like Minecraft, when you start hitting a block.

The closest thing that I found was this shader

http://answers.unity3d.com/questions/204541/shaders-to-show-damage.html

but I think it's outdated, it has some errors.

Anyway, which direction should I be heading? right now I have it doing this

 if (hitPoints <= 80) spriteRenderer.sprite = damagedSprite;

but that's just replacing the sprite.

Thanks a lot!!

Comment
Add comment · Show 3
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 HarrisonJH · Jan 14, 2015 at 04:11 AM 0
Share

make an animation. In animator, normalSprite -> animation -> brokenSprite

avatar image Fornoreason1000 · Jan 14, 2015 at 04:35 AM 1
Share

another way you could do it is to program a decal shader for sprites. You may of noticed the other Diffuse > Decal shaders unity has for regular 3d Objects. These shader will get a texture , and add another on top of it. which is similar what $$anonymous$$ecraft does(you'll notice in the texture packs of $$anonymous$$e craft the cracks and textures are stored separately).

I'm not a shader programmer myself, but the way I'd sort of do it , is draw one pixel from the first texture, then draw another on top of it from the second, the first texture being your sprite and the second being the progressive animated cracking sprite. you will need to animate in a script

another way might to be just to mix the color samples from the two textures (add, multiple, divide or subtract).

Anyway I'm not sure how the Sprite shaders work, I've only worked with a little 3D Diffuse type shaders.

avatar image Hathakas · Jan 14, 2015 at 02:01 PM 0
Share

Thank you for the replies! If I make an animation, does that mean I have to animate each type of block? There's 100's of different ones lol. Having it replace the sprite is also a problem as I'll have to make each block have a few phases. That's why I though it needs to be shaders. Unless I'm missing something? Fornoreason1000 I'm going to try what you said but I have no experience playing with shaders so may take a while to figure out lol.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Pflobus · Jan 14, 2015 at 04:25 AM

Yes. So, you could make an animation, and like a boolean (hit) that would be: hit = false, and when it's hit, it becomes hit = true, playing the animation, or you could replace the sprite.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2D Sprite Always Visible - Shader / Material not working (ZTest, ZWrite, Culling) 1 Answer

Render sprite only on top of a specific sorting layer 1 Answer

2D Sprite Highlight 0 Answers

Is it possible to have multiple stencil reference values in one shader? 0 Answers

Pixel snap for material made with Unlit Shader Graph? 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