How exactly can I find a point directly in front of and at any given distance from my main cam? For example, I’m looking for a point that’s exactly 2 units away from my main camera in the direction that it’s currently facing. Are there any functions that could help with this?
That’s a job for ViewportToWorldPoint: pass to it the vector (0.5, 0.5, distanceFromCamera), where 0.5, 0.5 means the center of the screen:
// returns a point exactly 2 meters in front of the camera: var point = Camera.main.ViewportToWorldPoint(Vector3(0.5, 0.5, 2.0));
A much needed correction.
var point = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 2.0f));