Confusion trying to set position at an angle
I am confused about the math needed to solve the following problem. I have an object which can be rotated 360 degrees so it could be facing anywhere. I have a vector i need the object to be set at but only on the axis it is facing. I have drawn a quick diagram to explain things clearer.
The blue line is the axis the object A should move on
The purple point B is the point to be set near
The red point is where A should be
Ultimately i need to set the red point every frame as A will be rotating and B will be moving. I would love if any answers would have an explanation so i can develop them into my game better. I cant find help on this anywhere and I really need to try and get the most efficient answer i can. If you can point me toward any information to help me i will be very grateful
Answer by doublemax · Oct 06, 2016 at 11:00 PM
https://docs.unity3d.com/550/Documentation/ScriptReference/Vector3.Project.html
This should do what you need. If you need further explanation, ask again.
This is exactly what i need. I never would have found it without you help, and the unity doc has all the explanation i could need. Its crazy how often ive been saved by a single line of code. Thanks a million!