PLease heeeeelp with smooth camera :(

Please any smart wizard out there help, I need a camera follow script that will follow my player vertically on the Y axis. My project is 2D. I have tried so many scripts. My problem is stuttering. The camera stutters randomly when I keep jumping up. The camera only follows the player up and down using smooth damping but stutters randomly. . . .:the game runs well at stable 60Fps on device and PC but keeps stuttering. . .I have profiled it and everything looks well, I have tried fixed update, late update. Rigidbody interpolation but still. . .the follow script can follow smoothly if the player plays and moves on the x axis but since I keep moving him up I get stuttering camera movements. . . .I can’t really post any scripts since I am posting this on my old phone. . . . .I just hope someone can offer me some clue or a script that can follow a player upwards (my player jumps using a rigidbody).

I just hate them stutters! ! ! What can cause stuttering in a 2D physics? (Boxd2D)? What to look out for? Vsync on or off still I get this problem.

All I need is a camera that follows a player that has a rigidbody2D upwards or downwards. . .without that occasional stuttering.

Fixed update would make it worse I believe, you want late update so that the calculations and positioning of the camera happen after all other objects are positioned. You want to calculate position using SLERP, or some other easing function, and you also want to switch the ridgidbody to interpolate. Only set the position of the camera once, in one script. You don’t want multiple scripts fighting over where the camera ought to go.

Those are the basic guidelines- Post your code as soon as you can.

Ok, so I changed the script to something like this and set my rigbody to interpolate, I still notice some hiccups at some intervals. But I haven’t tested on device yet, it could be my laptop screen.

Using UnityEngine;
Using System.Collections;

public class CamFollow : MonoBehavior
{

public Transform player;
public float smoothRate;
private Vector2 velocity = new Vector2(0.5f, 0.5f);

Void LateUpdate ()
{
Vector2 newPos2D = Vector2.zero;

newPos2D.y=Mathf.SmoothDamp(transform.position.y, player.position.Y + 1f, ref velocity.y, smoothRate);

Vector3 newPos = new Vector3 (transform.position.x, newPos2D.y, transform.position.z);

transform.position = Vector3.Slerp(transform.position, newPos, Time.time);

}
}

Please avail yourself of the code formatting feature found in the formatting button to the right of the video button.

I don’t think you want to use time.time in your slerp, for one thing. That number represents how far along in the interpolation the position returned is. Time.time increments every second. You probably want some kind of calculation using time.delta time or smoothed time. Delta time is the time between frames and is always less than 1.

I apologize about the format (typing with a phone). . .I hardly use the forum. Thanks dude for the replies, just tested it again on the device. Its smooth but only for some time. . .I think its time I rethink my game design and abandon this infinite jumper approach.

Have you looked at this? He uses smoothdamp as his easing function.

Turns out my game is just too fast paced for 60fps. . .after cranking things up on to 100fps(application. target frame rate ) the game behaved as it should. . .lol now come to think of it, a gamer would have to have ninja eyes to play this game. . .looks like I have to find a proper balance of forces( esp. Jump force and gravity) for the game to play nice under 60 FPS. 100fps would just drain the device’s battery too fast. . . .