generated from krampus/template-godot4
Using orbital camera shot tracking
This commit is contained in:
parent
a469af26f4
commit
ecc425f10d
|
@ -0,0 +1,28 @@
|
||||||
|
class_name OrbitalCamera extends Node3D
|
||||||
|
|
||||||
|
const POSITION_ACCELERATION := 4.0
|
||||||
|
|
||||||
|
@export var target: Node3D
|
||||||
|
|
||||||
|
@export var angular_speed := 0.01
|
||||||
|
|
||||||
|
@onready var camera: Camera3D = %Camera
|
||||||
|
|
||||||
|
static var scene := preload("res://src/player/orbital_camera/orbital_camera.tscn")
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
# Update position
|
||||||
|
global_position = global_position.lerp(target.global_position, delta * POSITION_ACCELERATION)
|
||||||
|
|
||||||
|
# Update rotation
|
||||||
|
camera.look_at(target.global_position)
|
||||||
|
|
||||||
|
# Update phase angle
|
||||||
|
rotation.y += angular_speed
|
||||||
|
|
||||||
|
|
||||||
|
static func create(_target: Node3D) -> OrbitalCamera:
|
||||||
|
var instance: OrbitalCamera = scene.instantiate()
|
||||||
|
instance.target = _target
|
||||||
|
return instance
|
|
@ -0,0 +1,14 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://de5onfk2tyr1d"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://src/player/orbital_camera/orbital_camera.gd" id="1_nvlic"]
|
||||||
|
|
||||||
|
[node name="OrbitalCamera" type="Node3D"]
|
||||||
|
script = ExtResource("1_nvlic")
|
||||||
|
|
||||||
|
[node name="Pitch" type="Node3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0.913545, 0.406737, 0, -0.406737, 0.913545, 0, 0, 0)
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera3D" parent="Pitch"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3)
|
||||||
|
current = true
|
Loading…
Reference in New Issue