What I'm trying to do is get an object's velocity to change with a smooth transition. The code is supposed to decrease the y-velocity by 0.1 each frame, until it reaches -2.5. However, whenever the code is executed, Unity freezes and becomes unresponsive. Does anyone know what the issue is?
void MoveDown() {
while (rb.velocity.y > -2.5) {
Vector2 newV;
newV.x = 0f;
newV.y = -.1f;
rb.velocity += newV;
}
}
↧