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 qrious_criss · Aug 17, 2016 at 01:26 PM · cameracamera-movementcamera followflickeringflicker

Gameobject flickers on camera follow. Solved but with silly method :/

im making an endless runner game, and everytime I play the game the runner was flickering. But at gameplay when I disable and re-enable the camera follow script component in the camera. the flickering just fixed. so I make a method to disable the camera follow script component at the start of the game and then re-enable it after a certain amount of time just to make the flickers go away. (silly method but works just fine)

I've tried a lot of different way from tweaking the setting to manipulating camera object, but no other solutions. (I even uninstal & re-instal unity ==`)

So I need to know why this is happening, is it a bug? and if there is another solution I'd like to know... I also leave the camera component setting to default.

This is the Player Script

 private CharacterController controller;
 private Float speed = 10;
 private  GameObject camFol;
 private bool moving;
 
 void Start () {
    controller = getComponent<CharacterController> ();
    camFol = GameObject.FindGameobjectWithTag("MainCamera");
    camFol.GetComponent<CameraFollowScript>().enabled = false;
 }
 
 void Update () {
   if (Input.GetKeyDown(KeyCode.Space))
     controller.Move (vector3.forwad * speed * time.deltatime);
     Moving = true;

  if (Moving)
     camFol.GetComponent<CameraFollowScript>().enabled = true;
 }

& this is the Camera follow Script

 private Transform lookAt;
 private vector3 startPosition;
 
 void Start () {
   lookAt = GameObject.FindGameobjectWithTag("Player").transform;
   startPosition = transform.position - lookAt.position;
 }
 
 void Update () {
   transform.position = lookAt.position + startPosition;
 }



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 FullMe7alJacke7 · Nov 07, 2018 at 02:59 AM 0
Share

Yeah, what everyone below posted. I'll elaborate as to why for you. What's happening is the scripts are competing against each other basically, it needs to be the FixedUpdate or LateUpdate because this runs after the regular update, if they're running at the same time it's like you camera is trying to follow something that hasn't fully moved yet basically.

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by aditya · Aug 17, 2016 at 01:44 PM

In Player script put your character movement code in FixedUpdate and in Camera follow script put the code that is updating the position of camera in FixedUpdate too

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
2

Answer by diedona · Nov 06, 2018 at 11:30 PM

I had the same problem, but solved it by putting camera code into LateUpdate and Player Script in Update.

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 $$anonymous$$ · Nov 07, 2018 at 12:08 AM

anything that involves physics goes into FixedUpdate

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Smooth camera on moving platform 1 Answer

How to make a camera zoom in on a specific point 1 Answer

Follow camera in 2d game 2 Answers

URGENT Cinemachine virtual camera while falling 1 Answer

Top down camera lock 2 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