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
0
Question by kevinseligmann · Apr 12, 2012 at 08:35 PM · cameramovementscreenblackflicker

Window flicker when moving camera

Hi people, I'm having a lot of trouble with something.

I have an ortographic camera, which when given the conditions I move to another point from one frame to the other. This means the movement is instantaneous and should not give any kind of problem.

The problem is, that whenever I press the button which moves the camera from a fixed point to another, there is a 1ms (just to say) flicker. This flicker is like a black screen that lasts 1 frame, and sadly enough to perceive with the eye.

Does anyone know something about this? A workaround? A fix?

Thanks very much!

Comment
Add comment · Show 8
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 dkNinja · Apr 13, 2012 at 04:02 AM 0
Share

Can you provide a code sample? It's hard to debug this type of problem without looking at the exact methodology.

avatar image kevinseligmann · Apr 13, 2012 at 12:47 PM 0
Share

@dkNinja : Of course, the script is as it follows:

// We add the camera var gameCamera : GameObject;

// We list all the Scenes in the Game. var Scene1 : GameObject; var Scene2 : GameObject; var Scene3 : GameObject;

function changeScene(id : int){

 switch(id){
     case 1:
         // Scene 1
         gameCamera.transform.position = Scene1.transform.position;
         break;

     case 2:
         // Scene 2
         gameCamera.transform.position = Scene2.transform.position;
         break;

     case 3:
         // Scene 3
         gameCamera.transform.position = Scene3.transform.position;
         break;
 }        

}

As you can see, the movement is given by a changeScene function which is called from the OnClick callback of a Box Collider acting as a button. So there's no Update nor LateUpdate function available.

avatar image dkNinja · Apr 13, 2012 at 05:17 PM 0
Share

I seem to remember someone else having pointed this out on this question. However, I think the problem is that the change of the Camera position happens in the middle of the event loops before rendering the camera.

http://unity3d.com/support/documentation/$$anonymous$$anual/Execution%20Order.html shows that colliders are handled in the physics loop. Try to set a flag to make the move in the collider OnClick callback and actually make the move in a LateUpdate. This keeps the camera calculations that have been done up until now from being invalidated.

Let me know if this doesn't work. I'll try to replicate the problem on my project, then.

avatar image kevinseligmann · Apr 13, 2012 at 06:48 PM 0
Share

@dkNinja I'm sorry I have to say this out loud, but I really don't know anything about flags. I do understand what you say about the colliders being handled on the physics loop, but I don't know what to set a flag means.

Could you enlighten me a little about this so I can test it? Your help is much appreciated.

avatar image kevinseligmann · Apr 13, 2012 at 07:27 PM 0
Share

@dkNinja Thank you very much, I will test it right away and let you know any updates!

Show more comments

2 Replies

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

Answer by dkNinja · Apr 13, 2012 at 07:24 PM

No problem, flags are just a fancy way of saying a global variable. You could do something like:

 var newScene : int = 0;

 function changeScene(int id) {
     case 1:
     case 2:
     case 3:
         newScene = id;
         break;
 }

 function moveCamera() {
     switch(newScene){
         case 1:
             // Scene 1
             gameCamera.transform.position = Scene1.transform.position;
             break;

         case 2:
             // Scene 2
             gameCamera.transform.position = Scene2.transform.position;
             break;

         case 3:
             // Scene 3
             gameCamera.transform.position = Scene3.transform.position;
             break;
     }
 }

 function FixedUpdate() {
     if (newScene != 0) {
         moveCamera();
     }
 }

Something of this sort may prevent the flickering.

Edit: You would still call changeScene from other code to move the camera. Then this script would take care of delaying the call until the end of the frame.

Edit: Changed LateUpdate to FixedUpdate as pointed out by @kevinseligmann

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 kevinseligmann · Apr 13, 2012 at 08:06 PM 0
Share

Thank you VERY much for your help @dkNinja this surely helped me understand a little bit more about how Unity works. Thanks!

avatar image
0

Answer by JayMHelpsU · Apr 13, 2012 at 04:09 PM

The only thing i can think of is the refresh rate or the texture quality. Either one of those could be causing the flickering, try editing some values maybe in the 'Render Settings' I hope this helps, let me know the results. :)

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 kevinseligmann · Apr 13, 2012 at 04:56 PM 0
Share

@$$anonymous$$$$anonymous$$HelpsU I couldn't fin anything on Render Settings that would help me with this. The odd thing is that it really doesn't matter the texture quality, as my texture is child of the camera. I mean, the texture doesn't move if the camera doesn't.

I think I will try to fade in/out everytime I have to change the active window, to see if that solves the problem. But, it's not the best solution at all.

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

7 People are following this question.

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

Related Questions

Move the camera when the mouse reaches the edges of the screen 1 Answer

Game view is suddenly black 5 Answers

Flickering screen when development build disabled 0 Answers

Jerky Camera and Varying Translate speeds 1 Answer

Moving (teleporting) player and camera when they enter a certain area 5 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