Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 idlemind88 · Dec 27, 2018 at 07:47 AM · layerscamera followflickeringcamera.maindisappearing

[Question] Unity 2D Android game : Playspace and objects flickering and disappearing from game view after sometime of playing.

Hi, I designed a simple game for Android and was testing it (running smoothly for sometime) when suddenly the screen flickered and the player and the ground etc (the entire playspace, to be precise) disappeared from the Game view and only the camera background color (which I had set to brown) was visible for a few moments. Then the game resumed again and I was able to play when unexpectedy this happened again. All this time, the game was still going on, as seen from the Scene view.

Below is my code. I have also attached a couple of screenshots of the behaviour. This is intermittently happening after playing the game for sometime.

Could anyone please assist on how to get this resolved? Many thanks in advance for the help!

NOTE: I am using Cinemachine virtual cam to make the camera follow the player.

Code:-

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Player : MonoBehaviour
 {
     Rigidbody2D rb;
 
     Vector2 touchStartPos = Vector2.zero;
     Vector2 touchEndPos = Vector2.zero;
 
     Vector3 screenCenter;
 
     const float moveSpeed = 8f;
     const float jumpForce = 700f;
 
     void Start()
     {
         rb = GetComponent<Rigidbody2D>();
     }
 
     // Update is called once per frame
     void Update()
     {
         HandleMovement();
     }
 
     private void HandleMovement()
     {
         if (Input.touchCount > 0)
         {
             for (int i = 0; i < Input.touchCount; i++)
             {
                 Touch touch = Input.touches[i];
 
                 if (touch.phase == TouchPhase.Began)
                 {
                     touchStartPos = Camera.main.ScreenToWorldPoint(touch.position);
                     screenCenter = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width * 0.5f, Screen.height * 0.5f));
 
                     if (touchStartPos.y < screenCenter.y)
                     {
                         float xVel;
                         if (touchStartPos.x < screenCenter.x)
                         {
                             xVel = -moveSpeed;
                         }
                         else
                         {
                             xVel = moveSpeed;
                         }
 
                         rb.velocity = new Vector2(xVel, rb.velocity.y);
                     }
                     else
                     {
                         if (IsGrounded() == true)
                         {
                             rb.AddForce(new Vector2(rb.velocity.x, jumpForce));
                         }
                     }
                 }
             }
         }
         else
         {
             rb.velocity = new Vector2(0, rb.velocity.y);
         }
     }
 
     private bool IsGrounded()
     {
         int layerMask = ~(LayerMask.GetMask("Player"));
         RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, Vector2.down, 1f, layerMask);
 
         if (hitInfo.collider != null)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
normal.png (27.0 kB)
blank.png (16.2 kB)
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 idlemind88 · Dec 27, 2018 at 07:55 AM 0
Share

Attaching a screenshot of my main camera settings for reference.

camera-main.jpg (128.1 kB)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by alex181189 · Apr 03, 2019 at 06:18 PM

Did you fix your problem? Im facing the same issue...

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

96 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

Related Questions

I can not find Cinemachine in package manager. There is no option of 'All Assets in package manager.' 1 Answer

Camera Problem 0 Answers

Camera Follow (Not Exact) 1 Answer

Camera follow 3 Answers

Gameobject flickers on camera follow. Solved but with silly method :/ 3 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