Hey guys. Yesterday i made a thread where i asked how i could fix the problem with my jittering. I saw many answers on other threads that you should turn on the interpolate setting. Well for me the interpolate setting does this (video attached)
link text
This is my movementScript:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float movementSpeed = 1;
public float JumpForce = 1;
private Rigidbody2D _rigidbody;
// Start is called before the first frame update
private void Start()
{
_rigidbody = GetComponent < Rigidbody2D >();
}
// Update is called once per frame
private void Update()
{
var movement = Input.GetAxis("Horizontal");
transform.position += new Vector3(movement, 0, 0) * Time.deltaTime * movementSpeed;
if(Input.GetButtonDown("Jump") && Mathf.Abs(_rigidbody.velocity.y) < 0.001f){
_rigidbody.AddForce(new Vector2(0, JumpForce), ForceMode2D.Impulse);
}
}
}
And this is my CameraFollowScript (you probably wont need that):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
public Transform target;
public Vector3 offset;
public float smoothFactor;
private void FixedUpdate()
{
Follow();
}
void Follow()
{
Vector3 targetPosition = target.position + offset;
Vector3 smoothPosition = Vector3.Lerp(transform.position, targetPosition, smoothFactor * Time.fixedDeltaTime);
transform.position = smoothPosition;
}
}
I want to turn on the interpolate setting because this could maybe stop the jittering but as you see in the video it does some weird stuff which is probably related to the movementScript but im still a total beginner and noob thats why i cant see where the problem in the coding is. If someone knows a solution which solves this problem please help me (also if you know a solution for the jittering problem in general you are more than welcome to write it in the thread
)