TinyAdventure/scenes/game.gd

24 lines
718 B
GDScript

extends Node3D
class_name Game
@onready var camera = %Camera
@onready var player = %Player
@onready var build_system:BuildSystem = %BuildSystem
var _player_camera_offset:Vector3 = Vector3.ZERO
# Called when the node enters the scene tree for the first time.
func _ready():
_player_camera_offset = camera.global_position - player.global_position + Vector3.UP * 1
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
if build_system.is_active:
player.process_mode = Node.PROCESS_MODE_DISABLED
else:
player.process_mode = Node.PROCESS_MODE_ALWAYS
camera.global_position = player.global_position + _player_camera_offset
camera.look_at(player.global_position)