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
1
Question by wesley · May 09, 2011 at 12:52 PM · texturetexturesmultipleshield

Shield texture (multiple) textures

hey guys i have added a dammage reciever to it (dammage Reciever) from the first person shooter is it possitble to lets say the shield hase 100% health at 100% to 75% texture 1 from 75%to 50% texture 2 and from 50% to 25% texture 3 texture 1 is a blue one stands for 100/75% texture 2 is a green one stands for 75/50% texture 3 is a red one stands for 50/25% i hope you get my drift

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
1

Answer by Justin Warner · May 09, 2011 at 12:55 PM

material mat1, mat2, mat3, mat4, mat5, matNone;

if shield_health == 100

do mat1

if shield_health <100 && > 75

do mat2

if shield_health <75 && > 50

do mat3

if shield_health <50 && > 25

do mat4

if shield_health <25 && > 1

do mat5

if shield_health <= 0

do matNone

Now fill it in with real scripting, and you be good =).

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 Bravini · May 09, 2011 at 01:11 PM 0
Share

just a small correction, ins$$anonymous$$d of if shield__health < x && > y it should be if(shield_health y)

avatar image Bunny83 · May 09, 2011 at 01:27 PM 0
Share

That's pseudo code ;) "Now fill it in with real scripting"

avatar image
0

Answer by Bunny83 · May 09, 2011 at 01:25 PM

Justin showed a way but i like a more versatile approach:

// JS

var shildTextures : Texture2D[]; var health : float; var healthDisplay : GUITexture;

function Update() { // get health as value between 0.0 and 1.0 var v : float = health / 100.0; v *= shildTextures.length; // this line will round it down to the next integer. var index : int = v; // make sure it doesn't get out of bounds index = Mathf.Clamp(index,0,shildTextures.length); // assign the selected texture healthDisplay.texture = shildTextures[index]; }

This script can handle any amount of textures. If you want 4 textures (0-25, 25-50, 50-75, 75-100) just set the array in the inspector to 4 and assign your textures. Make sure the first texture is the 0-25 and the last one the 75-100.

If you provide only 3 textures it will split up like 0-33, 33-66, 66-100

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 Justin Warner · May 10, 2011 at 12:53 AM 0
Share

Lol. I refuse to give people code if they haven't tried for themselves. They don't learn, then they come back, and expect more. Seen it many of times.

avatar image Bunny83 · May 10, 2011 at 02:06 AM 0
Share

:D yeah, i know, usually i follow the same principles, but in the end it's not only an answer for him ;). The question is general enough for me.

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

1 Person is following this question.

avatar image

Related Questions

TriPlanar Textures Not Working Properly 1 Answer

Most efficient way to create cubes with multiple textures 2 Answers

Baking multiple textures for Unity models workflow? 1 Answer

Multiple texture import settings? 2 Answers

How does the unity terrain shader handle an arbitrary amount of textures ? 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