Hello, can someone help me how can i make weapon sway to be fps independent… cuz when i turn on vsync it moves faster despite i used deltaTime or fixed update…
public float swaySmoothness = 6f;
private Vector3 initialPosition;
void Start(){
initialPosition = transform.localPosition;
}
void Update(){
float movementX = -Input.GetAxis("Mouse X") * swayAmount;
float movementY = -Input.GetAxis("Mouse Y") * swayAmount;
movementX = Mathf.Clamp(movementX, -maxSwayAmount, maxSwayAmount);
movementY = Mathf.Clamp(movementY, -maxSwayAmount, maxSwayAmount);
Vector3 finalPosition = new Vector3(movementX, movementY, 0);
transform.localPosition = Vector3.Lerp(transform.localPosition, initialPosition + finalPosition, swaySmoothness * Time.deltaTime);
}```
Thanks in advance for any help
(I reposted this cuz I posted it in the wrong section before)