I believe this is basic vector math, but I'm struggling with it.
I have 2 objects (3D space, x, y, z), A (weapon) and B (camera). I want to move A to B's location, but then offset A from B so that it is always in view of the camera.
endPosition = objA.worldPosition startPosition = objB.worldPosition distance = endPosition - startPosition objA.worldPosition = distance
How do I offset object A so that it will always be an certain distance away from B so it will be in view?
To give you an idea of what I am doing... I have a weapon in the world that the player can click on and inspect to modify from anywhere (no fixed rotation or position). I want to move this weapon closer to the camera so they can turn it around, add attachments etc. Right now the weapon clips into the camera so I need to apply an offset.