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 cowmilk9 · Dec 04, 2013 at 01:12 AM · 3d textdepthmaskbattle-system

How do I create a scrolling HP meter? (EarthBound style)

I want to create a battle system very similar to the game EarthBound's. One big issue I'm having right now though, is getting the scrolling HP and PP meters working correctly and making them look at least passable. I need to somehow make the numbers scroll up and down with a delay (so the player has time to save themselves before they die). But I'm having trouble making this look good.

It was suggested that I use transparent planes to hide a scrolling list of numbers from 0-9 to hide the numbers that shouldn't be displayed. I don't know how to do this though. I've tried using a Depth Mask Shader to cover the 3DText numbers. I'm just not sure what the best way to go about doing this would be. Any suggestions would help.

Also, if you don't know what I'm talking about, look up "EarthBound Battle System" on YouTube and you'll see just what I'm trying to accomplish.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Dec 04, 2013 at 02:12 AM

I looked closely at several EarthBound videos. What I saw with the digits counting up. I did not see any scrolling. I've written the count-up type counter a couple of times. My methods was to use a texture atlas and change the uvs of the texture to change to a different digit. This is pretty easy using third-party tools like NGUI and EZGUI. Unity's new sprite might also work (I've barely started to play with it). Doing it without support tools would be a bit of work.

You can also do it using a text presentation component like GUIText, TextMesh or GUI.Label().

Here is a quick script that can be attached to a GUIText object. I it hard-coded to 3 digits, but with a bit of work it could be generalized:

 #pragma strict
  
 @script RequireComponent(GUIText) 
 
 public var delay = 0.2;
 
 private var vals : int[] = [0,0,0];
 private var _vals : int[] = [0,0,0];
 
 public var score = 0;
 private var _score = 0;
 
 function Start() {
      SetScore();
     InvokeRepeating("SetVal", 0.0, delay);
 }
 
 function SetNewScore() {
     score = Mathf.Clamp(score, 0, 999);
     _score = score;
     var t = score;
     var s = score;
     t = t / 100;
     vals[2] = t;
     t = s - t * 100;
     s = t;
     t = t / 10;
     vals[1] = t;
     t = s - t * 10;
     vals[0] = t;    
 }
 
 function SetVal() {
     if (score != _score) {
         SetNewScore();
     }
     var bChange = false;
     for (var i = 2; i >= 0; i--) {
         if (vals[i] != _vals[i]) {
         _vals[i] = (_vals[i]+1) % 10;
         bChange = true;
         }
     }
     if (bChange)
         SetScore();
 }
 
 function SetScore() {
     guiText.text = _vals[2].ToString() + vals[1].ToString() + _vals[0].ToString();
 }
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

16 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

Related Questions

Battle system (networking upgrade) 2 Answers

Depth mask shader and Unity shadows 0 Answers

Rendering depending on world coordinates 1 Answer

3D Text Mesh : Font Texture change to a Blank (Black) On Project Save 1 Answer

How Can I Switch Focus Between 3D Text Buttons By Using The Keyboard? 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