![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ghost2120 |
the code i use for camera is:
extends KinematicBody
const MIN_CAMERA_ANGLE = -60
const MAX_CAMERA_ANGLE = 70
export var camera_sensitivity: float = 0.05
onready var head: Spatial = $Head
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _unhandled_input(event):
if event is InputEventMouseMotion:
_handle_camera_rotation(event)
func _handle_camera_rotation(event):
rotate_y(deg2rad(-event.relative.x * camera_sensitivity))
head.rotate_x(deg2rad(-event.relative.y * camera_sensitivity))
head.rotation.x = clamp(head.rotation.x, deg2rad(MIN_CAMERA_ANGLE), deg2rad(MAX_CAMERA_ANGLE))
head.rotation.x = clamp(head.rotation.x, deg2rad(MINCAMERAANGLE), deg2rad(MAXCAMERA_ANGLE))
I think you just said “X” axis here
ramazan | 2022-01-10 13:03