Ok so i need helps with this.
Still cant find where you can rotate camera around object like you can in blender.
The code below does simple thing:
If mouse3 button
is pressed - sets is_rotating = true
and while true run rotate_camera(
) function
This dont work..
extends Node3D
@onready var camera_3d: Camera3D = $Camera3D
@onready var mouse_status: Label = $CanvasLayer/Control/PanelContainer/VBoxContainer/HBoxContainer/MouseStatus
@onready var mesh_instance_3d: MeshInstance3D = $MeshInstance3D
var is_rotating = false
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
#var lol = InputMap.get_actions()
if event.is_action_pressed("action_mouse_middle"):
# Rotate
mouse_status.text = "Rotate"
is_rotating = true
if event.is_action_released("action_mouse_middle"):
# Rotate
mouse_status.text = "None"
is_rotating = false
pass
if event.is_action_pressed("action_mouse_left"):
# Rotate
mouse_status.text = "Left"
if event.is_action_released("action_mouse_left"):
mouse_status.text = "None"
pass
if event is InputEventMouseMotion:
if is_rotating:
rotate_camera(event)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func rotate_camera(event:InputEventMouseMotion):
camera_3d.rotate_y(deg_to_rad(-event.relative.x * 0.2))
camera_3d.rotate_x(deg_to_rad(-event.relative.y * 0.2))
camera_3d.rotation.x = clampf(camera_3d.rotation.x, deg_to_rad(-90), deg_to_rad(90))
camera_3d.rotate_y(event.relative.y * 0.0010)
camera_3d.rotate_x(event.relative.x * 0.0010)
pass
I know how to do the rotation if you put camera inside 2 nodes:
func _input(event):
if not is_multiplayer_authority(): return
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
$h.rotate_y(deg_to_rad(-event.relative.x * h_sensitivity))
$h/v.rotate_x(deg_to_rad(-event.relative.y * h_sensitivity))
$h/v.rotation.x = clampf($h/v.rotation.x, deg_to_rad(cam_v_min), deg_to_rad(cam_v_max))
But i want to be able to do the same with just the camera.. im sure its possible? If not then ill just use the player char setup to do this 🙁...