I need to cast a ray from the character’s position to the camera, while considering a target screen offset Vector2(-0.5, -1).
Without the offset, the ray correctly goes through the screen’s center, but with the offset applied, the ray direction and origin need adjustment to maintain the correct behavior (ray appears a bit left and bottom), I need it to go from the screen’s center as if there is no target offset.
How can I adjust both the origin and direction of the ray to account for the target offset effectively?
I created a PG attempt: https://playground.babylonjs.com/#SFOGSQ#1
arcCamera.setTarget(player);
var playerPosition = player.position.clone()
var direction = camera.getForwardRay().negate();
var ray = new Ray(playerPosition, direction, 6);