- Home /
Unity3D Choppy Camera Motion
I tried many different methods but never succeed to make a perfectly smooth camera movement. Even in a very simple scene, camera follow is not good enough. There are hiccups in motion. Hiccups do not occur periodically but randomly. If I didn't know some games(e.g. Manuganu) made in unity and has a perfect camera follow, I would think it is impossible. My scene is so simple, there are sprites, target character and camera. Target character seems normal always, but all other things jitter for a very short time, randomly, but disturbing.
What I have tried so far: -Change camera position in LateUpdate/FixedUpdate. -Made my target interpolate/extrapolate. -Moved camera depending on Deltatime. -Increased physics steps. -Set the targetframerate = 60. -Played with all Quality settings, Vsync etc. -Many variations and other things...-there is no GC issue
The best scenario is, random hiccups...happening in both mobile and editor. Unity's example scripts doesn't work perfectly smooth either. I can't continue developing sidescroll runner game because of this hiccup problem.
The question is: is there any way I didn't mention, is there any example on the Internet? I did everything I can do.
transform.position = new Vector3(target.x, target.y, -10); This is how I update camera position in LateUpdate.
PS: There is no FPS drop issue.
Have you solve this problem? I encounter same problem at this moment. If you fix this issue,please provide solution.
Still didn't find a solution and newer versions make it even worse. So I'm still using 4.6.
I am working on urgent project for TV broadcasting. And it requires high detail graphics and perfect camera smooth moving. Also I tried to many ways to fix this problem but I can`t find suitable solution.
I have encountered with the same problem. Still didn't find the solution. Did anyone get it?
Do you get stutter when you move character and mouse in the same time?
Answer by Socrates · Mar 25, 2015 at 08:38 AM
Have you tried using smoothing on the camera? This way when the player moves suddenly, the camera moves to follow, but flows more evenly.
The following is based on the code from the Survival Shooter tutorial in the Unity Learn section. The code goes on the camera. The "target" is the player.
using UnityEngine;
using System.Collections;
public class CameraFollow : MonoBehaviour
{
public Transform target;
public float smoothing = 5f;
private Vector3 offset;
void Start()
{
offset = transform.position - target.position;
// Or do offset = new Vector3(target.x, target.y, -10);
}
void FixedUpdate()
{
Vector3 targetCamPos = target.position + offset;
transform.position = Vector3.Lerp(transform.position, targetCamPos, smoothing * Time.deltaTime);
}
}
Believe it or not, I tried anything similar to your suggestion so far. I think the problem is with the game engine. You can have look at angry bots (example project comes with unity), It has the same issue but you may not recognize it until I say because it is not that important in such kind of a game. But if you are making something like flappy bird, it hurts. Honestly, I don't think there is a solution currently. Thanks for your advice anyways.
By the way, it may not be a camera follow issue. Just put a box with rigidbody and set a velocity then watch. You will see random hiccups.
I have played the Angry Bots demo on multiple versions of Unity and not had a problem with choppy camera in any of them.
Try making a build of the game and running it outside of the Unity editor. Sometimes things do now work properly in the editor.
Also, garbage collection can cause issues as the game hangs for a moment when a bunch of garbage collection happens. If you are creating and destroying a lot of objects over and over, look into object pooling.
Thanks for info. I know all your sayings and very low level issues. I tried angry bots with several devices, it is not easy to recognize it in angry bots but it happens. Note: you are right. it is not generally possible to have a good motion in the editor but devices.
Answer by Hrungdak · Mar 25, 2015 at 09:16 PM
Difficult to analyse without more information. If you bind your camera to the character in this way, every "hickup" of the character transforms 1:1 to the camera. And the effect is, that the camera and the character seem not to "hickup", but everything else does.
I would recommend either decoupling the camera from character by running some code to smooth the camera movement or searching for the error in the character movement.
Answer by XinJinXiang · Mar 25, 2015 at 08:50 AM
Yeah, as onculy mentioned above it is not camera follow issue. I tested in empty scene with simple cube many times. Also it moves well if you don`t want perfect camera moves. But I need perfect and smooth move for TV broadcasting.
Did anyone get the solution, i am facing the same problem mentioned in the main question. I have tried everything available on internet. Please post the solution if anyone has found it.
Your answer
Follow this Question
Related Questions
Cloud recognition in Vuforia 0 Answers
how to export unity project to the eclipse program 2 Answers
Problem with set fullscreen in webplayer 0 Answers
Collision detection on cube with third person camera 1 Answer
Set Active To Prefab 1 Answer