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 Porfyrios · Mar 09, 2011 at 12:27 PM · texturescreenhitflashred

Red flash for each network player when he gets hit

I am trying to make a multiplayer fps game. I want to flash a red gui texture for each player that gets hit by another player. I instantiate each player as a prefab. I tried to put the gui texture inside the prefab so that each player has its own red gui texture, but this doesnt work cause i cant see the texture after i instantiate it in the network.

For example when player2 gets hit by player1 i want to retrieve the guitexture of player2 and flash it in front of player 2. I hope u understand what i want to do.

Thnx in advance.

I am using this script for flashing the texure:

function Fade (start : float, end : float, length : float, currentObject : GameObject) { //define Fade parmeters if (currentObject.guiTexture.color.a == start){

for (i = 0.0; i < 1.0; i += Time.deltaTime*(1/length)) { //for the length of time currentObject.guiTexture.color.a = Mathf.Lerp(start, end, i); //lerp the value of the transparency from the start value to the end value in equal increments yield; currentObject.guiTexture.color.a = end; // ensure the fade is completely finished (because lerp doesn't always end on an exact value) } //end for

} //end if

} //end Fade

function FlashWhenHit (){ Fade (0, 0.8, 0.5, GUITextureobjectname); yield WaitForSeconds (.01); Fade (0.8, 0, 0.5, GUITextureobjectname); }

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 Chris 30 · Apr 03, 2011 at 07:01 PM 0
Share

ANy luck with this?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AngryOldMan · Mar 09, 2011 at 04:09 PM

in the players health/life script (what ever gives it hits points and makes it die when they get to zero) add a variable (boolean) called showGui or something like that which turns on after the line that subtracts health. Then have your red flash drawn as a GUI texture (2D texture, not sure if GUI texture is the right phrase) across the whole screen which is only called when showGui variable is true.

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 Porfyrios · Mar 09, 2011 at 05:18 PM 0
Share

i have done that. under the hp=hp-damage i have placed the code for the texture to be drawn and ins$$anonymous$$d of drawing the texture in front of the hurt player it draws in front of the active view.

avatar image AngryOldMan · Mar 10, 2011 at 01:08 AM 0
Share

ah your doing over the network I see. You can either put in a code like if ""(networkView.is$$anonymous$$ine)"" or (and this is messy but if all else fails) make seperate prefabs with seperate scripts (dependin on how many players you can have at one time.

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

No one has followed this question yet.

Related Questions

Screen flashes red when taking damage 3 Answers

Screen Flash When Hit -- Error Help From Pervious Question's Answer 1 Answer

How do I scale a texture so it appears as fixed sized regardless of the display size? 1 Answer

How do I take maximum screenspace for Gui 1 Answer

How to get texture coordinates without using MeshCollider? 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