Multiplying Vectors

Hey all, so I’m having slight problems with multiplying a move direction (vector) by speed (float). So I start the game off with a direction (1,1). Then the player catches the ball and gets a chance to aim his shot by doing (targetPos - playerPos).normalized (this works almost perfectly). The problem is the direction usually is in decimals, for example ( .3, .7). This causes a speed difference when i multiply by speed. Is there anyway i can fix this to move at a constant speed?

A direction of (1,1) is actually a magnitude of 1.4 or so (square root of 2).

Any nonzero vector passed through .normalized will be magnitude of 1.0

If you start the ball at (1,1) its speed is 1.4
If you start the ball at (1,0) its speed is 1.0

Either normalize your start velocity of (1,1) which will make it 0.7 / 0.7, or multiply your normalized output by 1.4

2 Likes

thanks so much that’s a nice easy fix and seems to be working perfectly!

1 Like