I have a point in space ‘A’ and we’ll say it’s located at vec3(0, 0, 0). There is a point that I don’t know ‘B’ that has the following criteria:
B.Y is equal to A.Y + SomeHeight
B’s Distance is SomeDistance
Is 45 degrees facing A’s backward direction
How do I calculate the x,y,z of this point?
Try to avoid ambiguous words like “forward” or “backwards” - forward relative to what? I’m facing forward right now, as are you, but I doubt we’re both facing the same direction. Forward or Backwards is a one dimensional term.
However, as you’re using Unity I will assume that by backwards you mean the direction that points along the negative Z axis as by default Forward in unity is usually positive Z.
Based on the information given what we need to find Point B is the direction vector or “normal” that points from A towards B. As it seems B lies on the YZ plane of the world axis (you mentioned no X axis information) calculating the direction vector is dead simple. We can even cheat a bit and let unity work it out by creating a point in that rough direction then ask unity to normalise it:
new Vector3(0,1,1).normalized.
y 1 and z 1 is a point 45 degrees up (from z) along the ZY plane (again I assume a positive angle here as you mention B.y is greater than A.y). The size of the values do not matter because we then ask unity to normalize it, this forces the magnitude (length) of the vector to 1. It actually ends up being about (0.0, 0.7, 0.7) and this allows us to multiply it by any number to find points in that direction at a specific distance.
Once we have this, simply multiply it by “SomeDistance” and you’ll have the position of B.
If “SomeDistance” is say 5 then B is at Vector3(0.0, 3.5, 3.5).