Comments and answers for "Get further vector based on vector direction"
http://answers.unity.com/questions/1767625/get-further-vector-based-on-vector-direction.html
The latest comments and answers for the question "Get further vector based on vector direction"Comment by Adrian-S492 on Adrian-S492's comment
http://answers.unity.com/comments/1768071/view.html
Thanks for post, it's not much more complicated indeed.
Of course naming convention is important, I just named this vectors as A, B, C so it's easier to create a scheme.Tue, 01 Sep 2020 18:30:59 GMTAdrian-S492Comment by Bunny83 on Bunny83's answer
http://answers.unity.com/comments/1767896/view.html
Yes, but if A is not the origin it's not really more complicated. All you do is remove A, scale your relative vector and add A back on ^^. In general if you do `B - A` you get the relative vector from A to B. This you can scale as you want. The final result can simply be added back to A to get to point C.
C = A + (B - A) * scale;
In distinct steps it's usually more readable, expecially with longer / meaningful variable names:
Vector3 AB = B - A;
C = A + AB * scale;
Note that if you want the resulting relative vector to have a certain length, you can normalize it before you scale it. That way the vector AB will have the exact length you specify.
Vector3 AB = B - A;
C = A + AB.normalized * newLength;
Always keep in mind that while code has to be readable / understandable by the compiler, it also should be readable and understandable by humans. The compiler doesn't care if you call your variable A, playerPosition or abz576eg5. A variable is just a variable. However you should write code that humans can understand easily. This is not only important when you work in a team where others might be watching or working on your code, but also for yourself. Try come back to more complicated code after a month, a year, ten years. If you have bad naming you will have a hard time to wrap your head around your own code.Tue, 01 Sep 2020 08:26:36 GMTBunny83Answer by Adrian-S492
http://answers.unity.com/answers/1767865/view.html
I was looking for a method or some kind of operation, but it turned out it's easier than I thought. In my case vector A was (0, 0, 0) so to get vector C i just need to multiply vector B by a certain number. If vector A is not Vector3.zero it's probably a little more complicated, but this idea still applies.Tue, 01 Sep 2020 07:17:41 GMTAdrian-S492