I am trying to make a slightly complex camera system. The reason it is complex is because the camera will move relative to, not just the player’s CFrame, but an NPC’s as well. I’ll attach some drawings in a dropdown so you see what I mean:
Hopefully you see what I’m trying to accomplish. The player will not be able to move the camera with the mouse at all; the camera will move every frame solely on what the positions (and rotations) of these two points are. If you need more clarifying, please let me know.
I have tried to get a vector along that middle line by doing the following:
local vectorInBetween = P1.Position - P2.Position;
vectorInBetween = vectorInBetween / 2; -- I do this so magnitude gets split in half
local part = Instance.new("Part");
part.Parent = Workspace; --The "Workspace" is a variable pointing to the correct way to access Workspace
part.CFrame = CFrame.new(vectorInBetween);
But the part spawns in a completely different area, not in between the two bricks I am testing with.
As stated in the drawing, I got the idea of using CFrame:lerp to get the midpoint in between them but I’m not sure on how to salvage the rotational part so that the camera moves relative to the points.
This is where I left off. I have no idea what to do next.
Also, in your answers, I would appreciate it if you didn’t just spit code and instead explain why and how something works so that I can learn from this experience.
Thank you in advance!