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

Why is this question downvoted/flagged? I don't see anything obviously wrong with it - it's not a duplicate (that I know of), the question is fairly clear, the grammar is good...

avatar image Tetrad · Jul 13, 2010 at 03:59 PM 0
Share

Fade out http://answers.unity3d.com/questions/12831/fade-in-from-black, Respawn http://answers.unity3d.com/questions/15078/trigger-respawn-after-collision, Falling Damage http://answers.unity3d.com/questions/6545/fall-damage-issue, plus the fact that there are multiple parts to the same question.

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 this 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 thisLight;
 float alphaFadeValue = 0.0f;

 // Use this for initialization
 void Start () {
     thisLight = light;
 }

 // Update is called once per frame
 void Update () {
     if(alphaFadeValue < .4)
     {
         alphaFadeValue += Mathf.Clamp01(Time.deltaTime / 10);
         thisLight.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

You can simplify your Start() with thisLight = light;

avatar image BoredKoi · Jul 13, 2010 at 12:13 PM 0
Share

Nice, yeah cleaner. Edit applied!

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

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

Need help with enemy respawn script 1 Answer

fade out effect when object disappear 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