Hello all,
I’m very new to coding and unity in general but i’ve started my first game and have run into a bit of a problem. It’s a 2D platformer, i have my player (cube), 2 platforms (one the ground, another smaller in the air to jump onto, both cubes as well), the script to move/jump my player, and camera script to follow my player.
The problem is the “lag” i get from the camera i am guessing. At first my player and the background (platforms) lagged as i ran or jumped. I have upped the damping and now the player is very smooth but the platforms still lag.
Any suggestions how to fix it or a better way to attach the camera to the player for a 2D platformer would be very much appreciated, thanks for your time.
Using C# btw,
Here is my Camera Script:
using UnityEngine;
using System.Collections;
public class SmoothFollow2 : MonoBehaviour
{
public Transform target;
public float distance = 3.0f;
public float height = 3.0f;
public float damping = 5.0f;
public bool followBehind = true;
void Update ()
{
Vector3 wantedPosition;
if(followBehind)
wantedPosition = target.TransformPoint(0, height, -distance);
else
wantedPosition = target.TransformPoint(0, height, distance);
transform.position = Vector3.Lerp (transform.position, wantedPosition, Time.deltaTime * damping);
}
}