Subindo repositorio
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
extends Node3D
|
||||
|
||||
@export_group("Properties")
|
||||
@export var target: Node3D
|
||||
|
||||
@export_group("Zoom")
|
||||
@export var zoom_minimum = 16
|
||||
@export var zoom_maximum = 4
|
||||
@export var zoom_speed = 10
|
||||
|
||||
@export_group("Rotation")
|
||||
@export var rotation_speed = 120
|
||||
@export var maximum_rotation_angle_x = -80
|
||||
@export var minimum_rotation_angle_x = -10
|
||||
|
||||
var camera_rotation:Vector3
|
||||
var zoom = 10
|
||||
|
||||
@onready var camera = $Camera
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
camera_rotation = rotation_degrees
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
self.position = self.position.lerp(target.position, 4 * delta)
|
||||
rotation_degrees = rotation_degrees.lerp(camera_rotation, 6 * delta)
|
||||
|
||||
camera.position = camera.position.lerp(Vector3(0, 0, zoom), 8 * delta)
|
||||
|
||||
handle_input(delta)
|
||||
|
||||
func handle_input(delta):
|
||||
var input := Vector3.ZERO
|
||||
input.y = Input.get_axis("camera_left", "camera_right")
|
||||
input.x = Input.get_axis("camera_up", "camera_down")
|
||||
|
||||
camera_rotation += input * rotation_speed * delta
|
||||
camera_rotation.x = clamp(camera_rotation.x, maximum_rotation_angle_x, minimum_rotation_angle_x)
|
||||
|
||||
zoom += Input.get_axis("zoom_in", "zoom_out") * zoom_speed * delta
|
||||
zoom = clamp(zoom, zoom_maximum, zoom_minimum)
|
||||
Reference in New Issue
Block a user