#Making a Camera3D to look at mouse position (first-person)
1 messages · Page 1 of 1 (latest)
Obviously I'll be doing research about the subject in the meanwhile, so I don't expect you to explain everything for me from the ground-up.
Reading about the subject, I now know how to project rays from my camera. How can I use that information then to rotate my view?
if you mean an ordinary first person camera from an FPS, wasd + mouse style, this would not normally be done with ray casting
you might search for ‘fps controls’ instead
Will do. Thank you. Have you ever implemented these controls by yourself?
So I found this code snippet online:
func _input(event):
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
var sensitivity = 0.2
var rotation = -event.relative.x * sensitivity
rotation.y += -event.relative.y * sensitivity
rotation.x = clamp(rotation.x, -90, 90)
camera.rotate_x(rotation.y)
rotate_y(rotation.x)
I understand what it's doing until line 4 (var rotation = -etc...)
Documentation says that rotation shouldn't be used, but instead transform.basis
I am taking this question to forums, because I am not getting the conversation I seek. Thanks anyways 🙂