init game files
This commit is contained in:
53
scripts/visual/TableCamera.gd
Normal file
53
scripts/visual/TableCamera.gd
Normal file
@@ -0,0 +1,53 @@
|
||||
class_name TableCamera
|
||||
extends Camera3D
|
||||
|
||||
## TableCamera - Isometric camera for the game table
|
||||
|
||||
# Camera settings
|
||||
@export var camera_distance: float = 18.0
|
||||
@export var camera_angle: float = 55.0 # Degrees from horizontal (higher = more top-down)
|
||||
@export var camera_height_offset: float = 0.0 # Offset to look slightly above center
|
||||
|
||||
# Smooth movement
|
||||
@export var smooth_speed: float = 5.0
|
||||
var target_position: Vector3 = Vector3.ZERO
|
||||
|
||||
func _ready() -> void:
|
||||
_setup_isometric_view()
|
||||
|
||||
func _setup_isometric_view() -> void:
|
||||
# Set perspective projection
|
||||
projection = PROJECTION_PERSPECTIVE
|
||||
fov = 50.0
|
||||
|
||||
# Calculate position - camera is positioned behind Player 1's side
|
||||
var angle_rad = deg_to_rad(camera_angle)
|
||||
|
||||
# Height based on angle
|
||||
var height = camera_distance * sin(angle_rad)
|
||||
# Distance along Z axis (positive Z is toward Player 1)
|
||||
var z_offset = camera_distance * cos(angle_rad)
|
||||
|
||||
# Position camera behind Player 1 (positive Z), looking toward center/opponent
|
||||
position = Vector3(0, height, z_offset)
|
||||
|
||||
# Look at center of table
|
||||
look_at(Vector3(0, camera_height_offset, 0), Vector3.UP)
|
||||
|
||||
target_position = position
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
# Smooth camera movement if needed
|
||||
if position.distance_to(target_position) > 0.01:
|
||||
position = position.lerp(target_position, smooth_speed * delta)
|
||||
look_at(Vector3(0, camera_height_offset, 0), Vector3.UP)
|
||||
|
||||
## Set camera to look at a specific point
|
||||
func focus_on(point: Vector3) -> void:
|
||||
var angle_rad = deg_to_rad(camera_angle)
|
||||
target_position = point + Vector3(0, camera_distance * sin(angle_rad),
|
||||
camera_distance * cos(angle_rad))
|
||||
|
||||
## Reset to default position
|
||||
func reset_position() -> void:
|
||||
_setup_isometric_view()
|
||||
Reference in New Issue
Block a user