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
1
Question by Sethhalocat · Aug 30, 2017 at 03:21 AM · 2d2d game2d-platformer2d sprites2d animation

2D Sprite Fillup without using UI

I have been trying extensively to find a way to allow a fill-up bar without having to use UI. My image for my game is to be able to watch the health of an enemy diminish over its head while attacking it, hit by hit. The one problem with this is that it appears to be impossible. Or so I think. I cant seem to find a way to do this and I've been playing with options extensively. Worst comes to worst, I just make the center of the image on the far left side and decrease the horizontal size throughout every update. But that seems very un-efficient. Any ideas?! Heres a picture below to represent my idea:

alt text

spickle.png (117.5 kB)
Comment
Add comment · Show 1
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 Sethhalocat · Aug 30, 2017 at 03:55 AM 0
Share

Currently I'm going with the option i decided beforehand by changing the texture to originate from the left side so the bar declines incrementally, however I would still like an actual fix to this rather than changing the scale....

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by game4444 · Aug 30, 2017 at 04:50 AM

I have attached a shader for the solution of your problem. You have to make a material and give this custom shader to that material. Select your material on your health bar sprite. You will get the option of fill value. then use that value accordingly. One thing you have to check shader may work in vertical not horizontal. If that problem comes open shader file and check x and y. Try to replace them and check. shader


shaderforfillup.zip (1.0 kB)
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 Sethhalocat · Aug 30, 2017 at 05:30 AM 0
Share

It works, I'll just rotate the sprite ins$$anonymous$$d. I appreciate your help and I did test it for a second but haven't added it to my script just yet. This really is a life saver. I looked everywhere for this and still couldn't find it. I don't understand why something like this isn't in unity by default. Thank you so much....

avatar image Sethhalocat · Mar 12, 2019 at 04:11 AM 0
Share

It's been a couple years, but going back to using this shader, I'm trying to figure out a way to have it work simultaneously with code. Something like HealthDisplayer.GetComponent(). that allows me to edit the fillup value would be great. or anything along those lines

edit: I figured it out! https://answers.unity.com/questions/340937/how-to-change-a-value-in-custom-shader-through-scr.html

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

127 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 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 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 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 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 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 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

How to sync animation if animation should be use with specially object 0 Answers

What is the best/easiest way to align a 2D rigidbody to specific sections of a sprite? 1 Answer

Help Me! I want to make a pixel fairy! 1 Answer

Pixelart distorts on import. 1 Answer

,Spawning snow or changing tilesets to snow as the player walks past them 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