• 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 Simon 2 · Jun 11, 2010 at 12:32 PM · damagerespawnfade

How to create a fade out respawn from falling?

I am working on an indie game and me and my team are in pre production. I am starting to put together a test build for testing the game mechanics. I have a question regarding programming: How to create a fade out respawn from falling?

-Fade out: When the player falls into the zone where they are forced to get damaged, I want the screen to fade out slowly and fade back in really fast when the player respawns.

-Respawn: I want to set spawn points and make the game determine where the player respawns by choosing the closest respawn point.

-Damage: Before the player respawns, I want the player to take actual damage w$$anonymous$$le falling. So the player doesn't die when they fall, but just receive a small portion of damage.

Comment
Add comment · Show 2
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 Cyclops · Jul 13, 2010 at 01:30 PM 0
Share
avatar image Tetrad · Jul 13, 2010 at 03:59 PM 0
Share

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by BoredKoi · Jun 11, 2010 at 04:26 PM

Well, there's all manners of ways to do the fading. Below is an example of a script placed on a GO representing your light, and how to fade out it with some time-stepping. Fading in would require reversing the manipulation on lightIntensity. I realize that the fading in t$$anonymous$$s example is packed in the update; in your case you could fire it off in a Coroutine. In fact, if you are applying damage, you could do that in concert with the fade out/back in action. As for respawning, ideally you'd have that collection of spawn Vector3[] points init'd and cached before game starts, as well as the transform of your player. That way you can simply iterate over that built in array, calling the static Vector3.Distance function and select the closest one to the player as the new spawn position.

using UnityEngine; using System.Collections;

public class LightFader : MonoBehaviour {

 public Light t$$anonymous$$sLight;
 float alphaFadeValue = 0.0f;

 // Use t$$anonymous$$s for initialization
 void Start () {
     t$$anonymous$$sLight = light;
 }

 // Update is called once per frame
 void Update () {
     if(alphaFadeValue < .4)
     {
         alphaFadeValue += Mathf.Clamp01(Time.deltaTime / 10);
         t$$anonymous$$sLight.intensity = alphaFadeValue;
     }
 }

}

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 qJake · Jul 09, 2010 at 06:48 PM 0
Share
avatar image BoredKoi · Jul 13, 2010 at 12:13 PM 0
Share

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Need help with enemy respawn script 1 Answer

fade out effect when object disappear 1 Answer

Respawned with Camera problem 2 Answers

Fade on death! 1 Answer

Player taking damage on collision. Can't get the script to work!? 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