Math Issue (Can't add relative offset)

I want to add an offset to the base location.

For debugging I tried drawing a debug sphere at the locations.
The base location is correct, it always stays a little bit ahead of the camera, no matter how the camera is rotated.
So it always has the same relative location to the camera.

However as soon as I add the offset, the location is not the same relative location to the camera. It changes as camera rotates.

How to add an offset to my base location, without messing it up?

Try multiplying the forward vector by a float, not a vector.

1 Like

So this worked

But I absolutely do not get how is this mathematically different, than just multiplying all 3 floats as a vector, with the forward vector.

Multiplying (x1,y1,z1) * (x2,y2,z2) = (x1 * x2, y1 * y2, z1 * z2). It was distorting the forward vector along the x axis, a bit on the y and leaves z to 0.0 (10.0, 5.0 , 0.0).

When it’s by a float you’re essentially stretching or compressing the vector along its direction. So ForwardVector * (float) still keeps the same direction.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.