TinyAdventure/scenes/game.gd

25 lines
755 B
GDScript
Raw Normal View History

extends Node3D
2024-09-27 18:09:30 +02:00
class_name Game
@onready var camera = %Camera
@onready var player = %Player
2024-09-27 18:09:30 +02:00
@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):
2024-09-27 18:09:30 +02:00
if build_system.is_active and build_system.build_item != null:
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)