Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Johanna_H · Jul 28, 2017 at 01:01 PM · animationgameobjectvisibility

How to animate disappearing Object?

I want a GameObject like the cube do fade in or fade out when I want it to. With fading in and out I mean that the Object seems to disappear and slowly becomes invisible.

I know that if I want to make an Object invisible I can do gameObject.SetActive(false). But I want it to be animated. I also tried changing the Renderers alph over time. That works but doesn´t look good. And even if the object is fully transparent you can still see it.

So I thought about creating a transparent wall that somehow hides the Object. So that you don´t see the wall and you don´t see the gameObject. I don´t know if this is even possible.

Does anyone have a better aproach about doing this? Or do you have any idea on how I would realize my idea? Thanks in advance!

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 RalphWeis · Jul 28, 2017 at 01:09 PM 0
Share

Have you try this

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by look001 · Jul 28, 2017 at 01:41 PM

you need shaders for this.

 Shader "Custom/Fade" {
     Properties
     {
         _Color ("Color", Color) = (1,1,1,1)
         _MainTex ("Albedo (RGB)", 2D) = "white" {}
         _Glossiness ("Smoothness", Range(0,1)) = 0.5
         _Metallic ("Metallic", Range(0,1)) = 0.0
         _Visibility ("Visibility", Range(0,1)) = 1
     }
     SubShader
     {
         Tags {"Queue" = "Transparent" "RenderType"="Transparent" }
         LOD 200
    
         CGPROGRAM
  
         #pragma surface surf Standard fullforwardshadows alpha:fade
         #pragma target 3.0
  
         sampler2D _MainTex;
         float _Visibility;
  
         struct Input {
             float2 uv_MainTex;
         };
  
         half _Glossiness;
         half _Metallic;
         fixed4 _Color;
  
         void surf (Input IN, inout SurfaceOutputStandard o)
         {
             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
             o.Albedo = c.rgb;
             o.Metallic = _Metallic;
             o.Smoothness = _Glossiness;
             o.Alpha = _Visibility;
         }
         ENDCG
     }
     FallBack "Standard"
 }

This is a basic Standard Surface Shader. I modified a bit so you can change the visibitily. All you need to do is make a script that changes the _Visibility value.

 bool FadeIn() {
     float val = Mathf.Lerp (0, 1, t);
     t += speed * Time.deltaTime;
     renderer.material.SetFloat ("_Visibility", val);
     return t > 1;
 }

If the Fade is done the method returns true. After every fade you need to reset the variable t to 0. Good Luck!

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 Johanna_H · Jul 31, 2017 at 06:47 AM 0
Share

Thank you so much!!! This is working exactly as I imagined!

avatar image
0

Answer by · Jul 28, 2017 at 01:36 PM

You need to create your own shader if ou want it to be perfect. Plugins like Amplify Shader and Shader Forge can help you create it.

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
avatar image
0

Answer by K0ST4S · Dec 21, 2018 at 10:29 AM

If you have SpriteRenderer, you can create animation where you change alfa value of color from 1 to 0 over time.

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.

Follow this Question

Answers Answers and Comments

188 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Keyframes of animated Child gameobject not shown by parent gameobjects animator issue ? 0 Answers

Objects in Hierarchy Not Visible Anywhere 0 Answers

Does the Singleton GameObject need to be in all scenes where i need to access it? 2 Answers

Randomly genrerated movement not working. 1 Answer

GameObject as a toggle button to play character Animation 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