- Home /
Reducing magnitude by x amount
This may be an easy one.
I've got a Vector, and i wish this Vector to be identical in angle, but 5 units shorter. Basically I;m looking to reduce the Magnitude by 5 units.
I've git working code, but I'm worried about using Normalize, and slowing things down unnecessary. Is there a better way of doing this?
attackVector = attackVector.normalized * (5 - attackVector.magnitude);
As always, thanks, you lot rock.
Comment
Answer by Nition · Nov 17, 2016 at 09:14 PM
Nope, .normalized is the best way to do what you're doing. There isn't really anything faster that'll give the same result.
Sorry for the four year wait on this reply, I type very slowly.
Your answer
![](https://koobas.hobune.stream/wayback/20220613075037im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rigidbody magnitude 3 Answers
force.normalized * magnitude 1 Answer
How to get a vector magnitude without calculating the square root? 1 Answer