My game is a bit laggy after applying Time.deltatime

Hi everyone, some “new guy” here, in fact this is my first post :slight_smile:

I’ve been making a few games in Unity, but I’m experiencing some problems with the newest game that I’m working on.
So far it has been running stable enough, but after applying Time.deltatime to the movement i have had a few lags while playing.

You can try it yourself here: http://mathias-s.dk/coptergame/

I think the lags might come from the camera trying to follow the player, but i dunno…
So if it is that, what is the best way of getting the camera to follow the player object in only one axis?

Currently i’m doing it this way:

//Code for the camera
transform.position = new Vector3(playerObject.transform.position.x + PLAYER_OFFSET, transform.position.y, transform.position.z);

Try to move the camera in LateUpdate()

You can get a jumpy camera if you update the camera before the player, as the camera has to wait for the next draw call before it is matched up to the player (who is then moved again).

You can also try:
OnPreCull()

that would guarantee your camera is always the last thing updated.

Gee, thanks!

LateUpdate() totally fixed it :smile: