Hey Guys,
I am working on a clasical 2D platformer game somethig similar to Mario Bros. The game is working fine. Camera follows the player smoothly. But when I jump the camera still follows the player. What I want is the camera to wait until the player is above its 1/2.
I want the camera to follow the player on the X axis smoothly and constantly - that is working fine. But on the Y axis I want the camera to wait and as soon as the player touches more than 1/2 of the camera range then change the transform of the camera on the Y axis exactly like Mario Bros.
Here is my simple smooth follow script that follows the player all the time:
public float dampTime = 0.25f;
private Vector3 velocity = Vector3.zero;
public Transform target;
void Update ()
{
if (target.position.x > 0)
{
Vector3 point = camera.WorldToViewportPoint(target.position);
Vector3 delta = target.position - camera.ViewportToWorldPoint(new Vector3(0.3f, 0.4f, point.z));
Vector3 destination = transform.position + delta;
transform.position = Vector3.SmoothDamp(transform.position, destination, ref velocity, dampTime);
}
}