Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | akaguriookami |
good night / good morning / good afternoon I’m having a problem with a script where the camera moves from top to bottom but not from left to right, can someone help me?
extends Spatial
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
pass
func _process(delta):
if Input.is_action_just_pressed(“ui_cancel”):
if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
#get_tree().change_scene()
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
pass
func _input(event):
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
VarPlayer.rotacaoCabeca.rotate_x(deg2rad(event.relative.y * VarPlayer.mouse_sensitivity))
VarPlayer.rotacaoPlayer.rotate_y(deg2rad(event.relative.x * VarPlayer.mouse_sensitivity * -1))
var camera_rot = VarPlayer.rotacaoCabeca.rotation_degrees
camera_rot.x = clamp(camera_rot.x, -70,70)
VarPlayer.rotacaoCabeca.rotation_degrees = camera_rot
pass
It’s hard to read your code but I think you swapped your x and y in these 2 lines:
VarPlayer.rotacaoCabeca.rotatex(deg2rad(event.relative.y * VarPlayer.mousesensitivity))
VarPlayer.rotacaoPlayer.rotatey(deg2rad(event.relative.x * VarPlayer.mouse_sensitivity * -1))
timothybrentwood | 2021-12-11 01:28