• 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 /
  • Help Room /
avatar image
0
Question by guendas · Jan 09, 2016 at 12:14 PM · animationpositionplayerfading

how to fade away scene for few seconds

I'm a newbie with Unity. I'm programming a simple game, in which the player has to collect some objects. What I would like to do is that after he collects an object, the scene fades away for few seconds and then the player position is changed. I know how to change the position, I have no idea how to make the fade away effect. I've tried using the Image Effect (such as Vortex and Blur) but I'm no able to slowly increment their variables (e.g. angle value for Vortex and blur iteration for blur) so that gives the impression of an animation.

Could someone guide me throw this?

Thank you very much!

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
0
Best Answer

Answer by brunocoimbra · Jan 09, 2016 at 04:55 PM

You can play around with coroutines and Color.Lerp, changing the image's color by a few seconds and then returning it to normal.

Here is a script for you, use it as a base to implement what you really want:

 using System.Collections;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class FadeManager : MonoBehaviour
 {
     [SerializeField]
     private Color opaqueColor = Color.black;
     [SerializeField]
     private Color transparentColor = Color.clear;
     [SerializeField]
     private Canvas canvas;
     [SerializeField]
     private Image image;
 
     private void Start()
     {
         canvas.enabled = false;
     }
 
     public void Fade(float duration)
     {
         duration *= 0.5f;
 
         if (duration <= 0)
         {
             duration = Time.deltaTime / 2;
         }
 
         StartCoroutine(IFade(duration));
     }
 
     private IEnumerator IFade(float duration)
     {
         canvas.enabled = true;
 
         image.color = opaqueColor;
 
         for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / duration)
         {
             image.color = Color.Lerp(opaqueColor, transparentColor, t);
 
             yield return null;
         }
 
         image.color = transparentColor;
 
         for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / duration)
         {
             image.color = Color.Lerp(transparentColor, opaqueColor, t);
 
             yield return null;
         }
 
         image.color = opaqueColor;
 
         canvas.enabled = false;
     }
 }

I didn't tested the code, but it should work.

Comment
Add comment · Show 1 · 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 guendas · Jan 10, 2016 at 09:58 AM 0
Share

Works perfectly!!

Thank you very much!! :)

avatar image
0

Answer by Sparkblack · Jan 10, 2016 at 07:23 AM

hi there,what you are looking for is in the learn section.under animation, or follow survival shooters final tutorial (gameover).

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

´How to check if 3D player is moving? 0 Answers

Multiple clips from the same Animation? 1 Answer

Proper way to implement animations 0 Answers

How to restart game where i start with.(Unity 3D) 2 Answers

How to constrain first person player to a path? 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