- Home /
Issue with camera (Shaking)
Someone explain this mistake!
Video : http://www.youtube.com/watch?v=8YK2IofeUgY
Code used :
using UnityEngine;
using System.Collections;
public class CameraControl : MonoBehaviour
{
public Transform target;
public float distance = -10f;
public float lift = 1.5f;
void Update()
{
transform.position = target.position + new Vector3(0, lift, distance);
transform.LookAt(target);
}
}
are you sure that camera is shaking? check values of position in Inspector on run. What is your target object?
$$anonymous$$eep your scene open as well and select camera so you can see what the camera is doing compared to the objects.
Use 'SmoothFollow' Script under Unity Standard Assets>Scripts>Camera to get started.
I can see there's more to that than just this script because you are moving camera toards the target
are you by any chance multiplying camera rotation with time.delta time? or something at that stuff?
I know because I had same issue, ...
Try using LateUpdate so the camera moves after everything else does. Also (as suggested by sethuraj use the SmoothFollow script), consider lerping ins$$anonymous$$d of hard setting the position :
transform.position = Vector3.Lerp( transform.position, target.position + new Vector3(0, lift, distance), 0.95 ); // use a float between 0 and 1 for lerp factor
Answer by hirenkacha · Oct 24, 2013 at 11:47 AM
Simply use LateUpdate()
instead of Update()
for camera script.
Wow!Brilliant!This is it!
Can you explain why does this happen?
And thanks to everyone!
@Tjandy98 it happens due to referencing and transfor$$anonymous$$g position and rotation of two objects simultaneously in Update Function. So in Update let the target get transformed and in LateUpdate() let camera get refer to that position. So this is done turn by turn.
Still its shaking little bit.Can you tell me what is reason behind it?
Answer by luckruns0ut · Oct 22, 2013 at 12:11 PM
Try unparenting the camera, if you haven't done so already.
Guys,please download my project,I don't understand I tried it too,but the camera have like 5 lines please help!!
http://www.megafileupload.com/en/file/463289/ProjectLearning-rar.html
Someone please explain :(
Your answer

Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Collider/Rigidbody issue.Camera shaking! 3 Answers
Multiple Cars not working 1 Answer
I need help with TPS controls! 0 Answers
How to make the Health bar on Enemys head not be in relation to Player(main) Camera? 2 Answers