I’m working on an FPS and I was wondering how to get the vector the camera is looking at.
I’d like to use the vector to spawn a projectile.
The code is already working, but only if I face a certain direction.
Since it’s a shooter, I want the projectiles to spawn in front of the player, no matter which direction they’re facing.
If you have entity that the camera component is attached to, you can use cameraEntity.forward where cameraEntity is the entity that the camera component is attached to.
For whatever reason, this.camera is null on FirstPersonMovement script despite what is shown in the editor. This meant that a new camera is created in the first update of the script which is the one being rendered and controlled by the mouse.
I cleared the entry in the script in the editor and reassigned it the Camera in the scene again. After that, it works as expected.
I tried it myself, AND I tested to see what direction my camera was facing (it outputs the correct direction), but my code still only works at a certain angle.
I want to make the floating cube to the right of where the player starts change its material to the brick texture when you look at it but so far that only works when you are at a certain position relative to it