-
What do you want to achieve?
Currently I am making a custom renderer of sorts using raycasts, similar to stuff like the original Doom and Wolfenstein 3D. -
What is the issue?
The issue comes from the side of rendering entities, I have no idea how to accurately position them on the X axis of the screen. Currently I got an angle between the entity and the camera, but it only does positive values, which is where the issue resides, since I don’t know if the entity is to the left or right. -
What solutions have you tried so far?
I tried looking for a solution online, didn’t find anything.
Here’s the angle/direction code:
local observerLook = (camera.CFrame.LookVector * Vector3.new(1,0,1)).Unit
local targetDirection = ((entities[index].Position * Vector3.new(1,0,1)) - (origin * Vector3.new(1,0,1))).Unit -- direction from observer to target
local angle = math.acos(observerLook:Dot(targetDirection))
The value returned is always positive, so I can’t know if the entity is to the right or left