|
|
|
|
|
by kaibee
796 days ago
|
|
Yeah looks like the calculation doesn't renormalize the final thrust vector after adding together the component inputs. A simplified example for a 2d game would be like this: var playerX_input = Input.GetHorizontal(); // float in range -1 to 1
var playerY_input = Input.GetVertical(); // float in range -1 to 1
var playerVelocity = new Vector2(playerX_input, playerY_input);
// The player can now move 1 unit/frame in X and 1 unit/frame in Y, which means that if they're moving diagonally, the length of their velocity vector is the length of the vector (1,1) which is sqrt(2) (~1.41)
// This can be corrected by doing something like
if(playerVelocity.length > 1)
{
playerVelocity = playerVelocity.normalized();
}
|
|