- Home /
Question by
kavehmb2000 · Sep 20, 2015 at 07:44 AM ·
camera movementcamera script
why unity camera scrolling updates scene only after transition has finished?
I repost my question on stackoverflow in hope of having an answer.
I'm trying to make my camera scroll over my scene as the game starts (Something like an intro). here is the code attached to my main camera:
using UnityEngine;
using System.Collections;
public class cameraScript : MonoBehaviour {
public float camYLerpTime = 5000f;
float camYInitPoint = 950f;
public float camYEndPoint = 0f;
float camPosY;
//float camFieldOfViewStable = 170.5f;
// Use this for initialization
void Start () {
camIntro ();
}
void LateUpdate () {
if (transform.position.y!=camYEndPoint) {
transform.position = new Vector3 (transform.position.x, camPosY, transform.position.z);
}
}
void camIntro()
{
camPosY = Mathf.Lerp (camYInitPoint, camYEndPoint, camYLerpTime * Time.deltaTime);
}
}
However, I only see the rendered scene as transition is finished and the camera is in it's final position. What am I doing wrong?
Project settings: 2D Unity version: 5.1.2f1
Comment
$$anonymous$$athf.Lerp is misused. Serlite's answer on Stackoverflow solves the problem.
Your answer
Follow this Question
Related Questions
Smooth follow with Mouse Orbit element 0 Answers
[C#] Smooth Camera Movement Restrictions 0 Answers
Creating a file that records the player position during a game in xyz coordinates 0 Answers
Mouse Look Help 2 Answers
Camera that both orbits and follows 1 Answer