godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.77k stars 3.07k forks source link

Absent mouselook information #6425

Open CapybaraTV opened 1 year ago

CapybaraTV commented 1 year ago

Hello, I'll try to be short and direct. What do you need to make a First Person Shooter? Mouse look. What is not present at GODOT docs? Mouse look.

https://docs.godotengine.org/pt_BR/stable/tutorials/inputs/mouse_and_input_coordinates.html

This page and nothing is the same thing. acomplishes nothing. The VOXEL 3d tutorial actually helps with mouse look. On the player script:

func ready(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _process(_delta):

Mouse movement.

_mouse_motion.y = clamp(_mouse_motion.y, -1550, 1550)
transform.basis = Basis(Vector3(0, _mouse_motion.x * -0.001, 0))
head.transform.basis = Basis(Vector3(_mouse_motion.y * -0.001, 0, 0))

func _input(event): if event is InputEventMouseMotion: if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: _mouse_motion += event.relative

Explanation: the ready function captures the mouse movement. The process function match the head(or camera) movement with the horizontal and vertical of the mouse. The input event function transfer the relative mouse movement every frame into a Vector to guide the camera.

Thats it. Thank you for your time. I hope this helps someone. God bless

CapybaraTV commented 1 year ago

Sorry. The code is wrong at line #Mouse Movement . The corect code is this: camera.transform.basis = Basis(Vector3(_mouse_motion.y -0.0005, _mouse_motion.x -0.0005, 0))

Calinou commented 1 year ago

This page and nothing is the same thing. acomplishes nothing.

I have to remind you that we have a Code of Conduct. Please stay constructive.