Hello.
Is there a way to prevent this from happening? If I hold “up” and my player reaches the top of the screen, Mathf.Clamp prevents it from going any further, but if I keep hold “up”, my player shakes like he’s trying to break through or something. It’s bizarre- here’s the code:
void FixedUpdate()
{
transform.position = new Vector3(transform.position.x,
Mathf.Clamp(transform.position.y, -3.479f, 7.25f),
transform.position.z);
// calculate the speed multiplier here from directionY
float speedMultiplier = GetSpeedMultiplier(directionY);
// use the speedMultiplier in place of directionY
rb.velocity = new Vector2(rb.velocity.x, speedMultiplier * moveSpeed);
}