Hi , I’m trying to make a 2D game and I’m trying to nail the movement down, but no matter what I use it’s always as I described it in the title, until I tumbled upon a characterController2D script made by Prime31 and when I used it the movement became buttery smooth in the right way I wanted to do it, I tried to understand the gentleman’s code but I’m not an expert so im still in the process of understanding it
this is a video to show the difference between my movement code (bottom cube) and prim31’s script (top cube)
[The video][1]
here is prime31’s
[2] on Github, and for me I used all possible ways of movement that I know of, through the rigidbody and or through the transform
so if I can get some insight on how to get same results without having to use prime31's code or at least how I could improve the jerkiness seen in video
pardon my English , thank you
[1]: https://www.kapwing.com/videos/5ca23f169254980013b02d2a
[2]: https://github.com/prime31/CharacterController2D/tree/master/Assets
@xxmariofer this is the script attached on camera
public Transform leftSideLimt, rightSideLimit;
public GameObject FollowTargetOBJ;
public float FollowSpeed;
//Paralax layers
public GameObject[] BackgroundROOTS;
private bool PlayerJustDied;
void Start ()
{
FollowTargetOBJ = GameObject.FindGameObjectWithTag ("Player");
}
void FixedUpdate ()
{
if (PlayerJustDied == false && FollowTargetOBJ.transform.position.x > leftSideLimt.position.x && FollowTargetOBJ.transform.position.x < rightSideLimit.position.x) {
//Smoothly Follow Target
Vector3 PositionBefore = transform.position;
Vector3 NewPosition = Vector3.Lerp (transform.position, FollowTargetOBJ.transform.position, FollowSpeed * Time.deltaTime);
transform.position = new Vector3 (NewPosition.x + 2.5f, NewPosition.y + 1.3f, transform.position.z);
//Paralax layer movement
Vector3 CameraMovementAmount = PositionBefore - this.transform.position;
BackgroundROOTS [0].transform.Translate (-CameraMovementAmount * 0.8f);
}
}
i set interpolate to interpolate…it started jerks,but when i set interpolate to none camera follows fine but characters movement is not smooth.Please help me out
Please use a cinemachine 2d camera and make it follow the player. That will help you better than hard coding a new camera, as well as giving you features you’ll enjoy…