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 sandro_lord · Sep 06, 2018 at 02:43 PM · 2dteleportingfade out

fade-teleport not working

hello! thanks for viewing my question. i am making a 2d game and i have a little problem. when i made teleport script, i wanted for it to fade out so the screen would get black and then return to normal. teleporting is easy, i did it, but my problem is fade. i made 2 points (2 teleporters) from which when i hit f it fades in black, and another doesn't (while teleporting from first point screen turns black and then returns to normal (how i want) but from another it doesn't turn black). here is the script: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;

 public class teleporter : MonoBehaviour {
     public GameObject player;
     public GameObject point1;
     public GameObject point2;
     bool inside;
     public Text text;
     public Image image;
     public Color transparent;
     Color aer;
     public Color black;
     bool ilaunched;
     bool fade;
     // Use this for initialization
     void Start () {
         inside = false;
         ilaunched = false;
         fade = false;
     }
     
     // Update is called once per frame
     void Update () {
         if (inside == true)
         {
             text.color = black;
             if (Input.GetKeyDown(KeyCode.F))
             {
                 player.transform.position = point2.GetComponent<Transform>().position;
                 ilaunched = true;
             }
         }
         if (ilaunched == true && fade == false)
         {
             aer.a = aer.a + 0.1f;
         }
         if (aer.a > 3)
         {
             fade = true;
         }
         if (ilaunched == true && fade == true && aer.a < 0)
         {
             fade = false;
             ilaunched = false;
         }
         if (ilaunched == true && fade == true)
         {
             aer.a = aer.a-0.1f;
         }
         image.color = aer;
     }
     private void OnTriggerStay2D(Collider2D collision)
     {
         if(collision.name== "player")
         {
             inside = true;
         }
     }
     private void OnTriggerExit2D(Collider2D collision)
     {
         if (collision.name == "player")
         {
             inside = false;
             text.color = transparent;
         }
     }
 }
 if i said something unclear, just reply and i will explain. thanks for seeing! 

definitions : aer-holder of color value so i assign it at end to image color text-the text says "hit f to interact" image-it is a black image with alpha value of 0. point1-from where to teleport , point2-to where to teleport

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 bpaynom · Sep 06, 2018 at 04:59 PM 0
Share

What is your GameObject point1; for ? You never use it. $$anonymous$$aybe it's part of your problem

avatar image sandro_lord bpaynom · Sep 08, 2018 at 10:35 AM 0
Share

point 1 is the point where player is standing to teleport , i thought i needed it when starting but later i did not need it. (plus this script is in point 1 so i dont know why i wrote it). it is not a part of the problem.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sandro_lord · Sep 08, 2018 at 10:36 AM

maybe i should make some kind of manager which will handle it from both teleport points? i will try it later, if it works i will tell you.

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

183 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

Related Questions

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 1 Answer

Teleporting my player to the other side of the screen? 1 Answer

Warping Up after jumping? 0 Answers

Collision for Amount of Time 1 Answer

how would I use teleport in in procedural generated rooms 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