mirror of
https://github.com/godotengine/tps-demo.git
synced 2026-01-01 01:48:39 +03:00
Use static typing in all scripts (#208)
This commit is contained in:
10
door/door.gd
10
door/door.gd
@@ -1,10 +1,12 @@
|
||||
extends Area3D
|
||||
|
||||
var open = false
|
||||
|
||||
@onready var animation_player = $DoorModel/AnimationPlayer
|
||||
var open: bool = false
|
||||
|
||||
func _on_door_body_entered(body):
|
||||
@onready var animation_player: AnimationPlayer = $DoorModel/AnimationPlayer
|
||||
|
||||
|
||||
func _on_door_body_entered(body: Node3D) -> void:
|
||||
if not open and body is Player:
|
||||
animation_player.play("doorsimple_opening")
|
||||
animation_player.play(&"doorsimple_opening")
|
||||
open = true
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var light_rays = $LightRays
|
||||
@onready var camera = get_tree().get_root().get_camera_3d()
|
||||
|
||||
func _ready():
|
||||
@onready var light_rays: CPUParticles3D = $LightRays
|
||||
@onready var camera: Camera3D = get_tree().get_root().get_camera_3d()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
await $AnimationPlayer.animation_finished
|
||||
queue_free()
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
func _process(_delta: float) -> void:
|
||||
if is_instance_valid(camera):
|
||||
light_rays.look_at(camera.global_transform.origin, Vector3.UP)
|
||||
light_rays.look_at(camera.global_transform.origin)
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
extends RigidBody3D
|
||||
|
||||
var puff_effect = preload("res://enemies/red_robot/parts/part_disappear_effect/part_disappear.tscn")
|
||||
|
||||
var _mat : Material = null
|
||||
var puff_effect: PackedScene = preload("res://enemies/red_robot/parts/part_disappear_effect/part_disappear.tscn")
|
||||
|
||||
var _mat: Material = null
|
||||
|
||||
@export var lifetime: float = 3.0
|
||||
@export var lifetime_random: float = 3.0
|
||||
@export var disappearing_time: float = 0.5
|
||||
@export var fade_value : float = 0.0 :
|
||||
@export var fade_value: float = 0.0 :
|
||||
set(value):
|
||||
fade_value = value
|
||||
if _mat:
|
||||
_mat.next_pass.set_shader_parameter("emission_cutout", fade_value)
|
||||
|
||||
var _disappearing_counter = 0.0
|
||||
var _disappearing_counter: float = 0.0
|
||||
|
||||
func _ready():
|
||||
|
||||
func _ready() -> void:
|
||||
set_process(false)
|
||||
if not OS.has_feature("dedicated_server"):
|
||||
var mesh := $Model.get_child(0) as MeshInstance3D
|
||||
@@ -24,21 +26,21 @@ func _ready():
|
||||
_mat.next_pass = _mat.next_pass.duplicate()
|
||||
|
||||
|
||||
func explode():
|
||||
func explode() -> void:
|
||||
# Start synching.
|
||||
$MultiplayerSynchronizer.public_visibility = true
|
||||
freeze = false
|
||||
if not multiplayer.is_server():
|
||||
return
|
||||
get_node("Col1").disabled = false
|
||||
get_node("Col2").disabled = false
|
||||
linear_velocity = 3 * (Vector3.UP).normalized()
|
||||
angular_velocity = (Vector3(randf(), randf(), randf()).normalized() * 2 - Vector3.ONE) * 10
|
||||
$Col1.disabled = false
|
||||
$Col2.disabled = false
|
||||
linear_velocity = 3.0 * Vector3.UP
|
||||
angular_velocity = (Vector3(randf(), randf(), randf()).normalized() * 2.0 - Vector3.ONE) * 10.0
|
||||
await get_tree().create_timer(lifetime + lifetime_random * randf()).timeout
|
||||
set_process(true)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
func _process(delta: float) -> void:
|
||||
fade_value = pow(_disappearing_counter / disappearing_time, 2.0)
|
||||
_disappearing_counter += delta
|
||||
if _disappearing_counter >= disappearing_time - 0.2:
|
||||
@@ -47,8 +49,8 @@ func _process(delta):
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func destroy():
|
||||
var puff = puff_effect.instantiate()
|
||||
func destroy() -> void:
|
||||
var puff: CPUParticles3D = puff_effect.instantiate()
|
||||
get_parent().add_child(puff)
|
||||
puff.global_transform.origin = global_transform.origin
|
||||
await get_tree().create_timer(0.2).timeout
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends CPUParticles3D
|
||||
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
$MiniBlasts.emitting = true
|
||||
await get_tree().create_timer(0.2).timeout
|
||||
emitting = true
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
|
||||
signal exploded()
|
||||
|
||||
enum State {
|
||||
APPROACH = 0,
|
||||
AIM = 1,
|
||||
SHOOTING = 2,
|
||||
}
|
||||
|
||||
const PLAYER_AIM_TOLERANCE_DEGREES = deg_to_rad(15)
|
||||
const PLAYER_AIM_TOLERANCE_DEGREES = deg_to_rad(15.0)
|
||||
|
||||
const SHOOT_WAIT = 6.0
|
||||
const AIM_TIME = 1
|
||||
const SHOOT_WAIT: float = 6.0
|
||||
const AIM_TIME: float = 1.0
|
||||
|
||||
const AIM_PREPARE_TIME = 0.5
|
||||
const BLEND_AIM_SPEED = 0.05
|
||||
|
||||
signal exploded()
|
||||
const AIM_PREPARE_TIME: float = 0.5
|
||||
const BLEND_AIM_SPEED: float = 0.05
|
||||
|
||||
@export var test_shoot: bool = false
|
||||
|
||||
@export var target_position := Vector3()
|
||||
@export var health: int = 5
|
||||
@export var state : State = State.APPROACH
|
||||
@export var dead = false
|
||||
@export var aim_preparing = AIM_PREPARE_TIME
|
||||
@export var state: State = State.APPROACH
|
||||
@export var dead: bool = false
|
||||
@export var aim_preparing: float = AIM_PREPARE_TIME
|
||||
|
||||
var shoot_countdown = SHOOT_WAIT
|
||||
var aim_countdown = AIM_TIME
|
||||
var shoot_countdown: float = SHOOT_WAIT
|
||||
var aim_countdown: float = AIM_TIME
|
||||
|
||||
var player = null
|
||||
var orientation = Transform3D()
|
||||
var player: Node3D = null
|
||||
var orientation := Transform3D()
|
||||
|
||||
var blast_scene = preload("res://enemies/red_robot/laser/impact_effect/impact_effect.tscn")
|
||||
var blast_scene: PackedScene = preload("res://enemies/red_robot/laser/impact_effect/impact_effect.tscn")
|
||||
|
||||
@onready var animation_tree = $AnimationTree
|
||||
@onready var shoot_animation = $ShootAnimation
|
||||
@onready var animation_tree: AnimationTree = $AnimationTree
|
||||
@onready var shoot_animation: AnimationPlayer = $ShootAnimation
|
||||
|
||||
@onready var model = $RedRobotModel
|
||||
@onready var ray_from = model.get_node("Armature/Skeleton3D/RayFrom")
|
||||
@onready var ray_mesh = ray_from.get_node("RayMesh")
|
||||
@onready var laser_raycast = ray_from.get_node("RayCast")
|
||||
@onready var collision_shape = $CollisionShape3D
|
||||
@onready var model: Node3D = $RedRobotModel
|
||||
@onready var ray_from: BoneAttachment3D = model.get_node(^"Armature/Skeleton3D/RayFrom")
|
||||
@onready var ray_mesh: MeshInstance3D = ray_from.get_node(^"RayMesh")
|
||||
@onready var laser_raycast: RayCast3D = ray_from.get_node(^"RayCast")
|
||||
@onready var collision_shape: CollisionShape3D = $CollisionShape3D
|
||||
|
||||
@onready var explosion_sound = $SoundEffects/Explosion
|
||||
@onready var hit_sound = $SoundEffects/Hit
|
||||
@onready var explosion_sound: AudioStreamPlayer3D = $SoundEffects/Explosion
|
||||
@onready var hit_sound: AudioStreamPlayer3D = $SoundEffects/Hit
|
||||
|
||||
@onready var death = $Death
|
||||
@onready var death_shield1 = death.get_node("PartShield1")
|
||||
@onready var death_shield2 = death.get_node("PartShield2")
|
||||
@onready var death_head = death.get_node("PartHead")
|
||||
@onready var death_detach_spark1 = death.get_node("DetachSpark1")
|
||||
@onready var death_detach_spark2 = death.get_node("DetachSpark2")
|
||||
@onready var death: Node3D = $Death
|
||||
@onready var death_shield1: RigidBody3D = death.get_node(^"PartShield1")
|
||||
@onready var death_shield2: RigidBody3D = death.get_node(^"PartShield2")
|
||||
@onready var death_head: RigidBody3D = death.get_node(^"PartHead")
|
||||
@onready var death_detach_spark1: CPUParticles3D = death.get_node(^"DetachSpark1")
|
||||
@onready var death_detach_spark2: CPUParticles3D = death.get_node(^"DetachSpark2")
|
||||
|
||||
@onready var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
orientation = global_transform
|
||||
orientation.origin = Vector3()
|
||||
$AnimationTree.active = true
|
||||
@@ -65,16 +65,17 @@ func _ready():
|
||||
collision_shape.disabled = true
|
||||
animation_tree.active = false
|
||||
|
||||
animate()
|
||||
animate(0.0)
|
||||
|
||||
func resume_approach():
|
||||
|
||||
func resume_approach() -> void:
|
||||
state = State.APPROACH
|
||||
aim_preparing = AIM_PREPARE_TIME
|
||||
shoot_countdown = SHOOT_WAIT
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func hit():
|
||||
func hit() -> void:
|
||||
if dead:
|
||||
return
|
||||
var param = "parameters/hit" + str(randi() % 3 + 1) + "/request"
|
||||
@@ -103,13 +104,13 @@ func hit():
|
||||
queue_free()
|
||||
|
||||
|
||||
func shoot():
|
||||
var gt = ray_from.global_transform
|
||||
var ray_origin = ray_from.global_transform.origin
|
||||
var ray_dir = -gt.basis.z
|
||||
var max_dist = 1000
|
||||
func shoot() -> void:
|
||||
var gt: Transform3D = ray_from.global_transform
|
||||
var ray_origin: Vector3 = ray_from.global_transform.origin
|
||||
var ray_dir: Vector3 = -gt.basis.z
|
||||
var max_dist: float = 1000.0
|
||||
|
||||
var col = get_world_3d().direct_space_state.intersect_ray(PhysicsRayQueryParameters3D.create(ray_origin, ray_origin + ray_dir * max_dist, 0xFFFFFFFF, [self] ))
|
||||
var col: Dictionary = get_world_3d().direct_space_state.intersect_ray(PhysicsRayQueryParameters3D.create(ray_origin, ray_origin + ray_dir * max_dist, 0xFFFFFFFF, [self] ))
|
||||
if not col.is_empty():
|
||||
max_dist = ray_origin.distance_to(col.position)
|
||||
if col.collider == player:
|
||||
@@ -117,24 +118,24 @@ func shoot():
|
||||
# Clip ray in shader.
|
||||
_clip_ray(max_dist)
|
||||
# Position laser ember particles
|
||||
var mesh_offset = ray_mesh.position.z
|
||||
var laser_ember = $RedRobotModel/Armature/Skeleton3D/RayFrom/LaserEmber
|
||||
var mesh_offset: float = ray_mesh.position.z
|
||||
var laser_ember: CPUParticles3D = $RedRobotModel/Armature/Skeleton3D/RayFrom/LaserEmber
|
||||
laser_ember.position = Vector3(0.0, 0.0, -max_dist / 2.0 - mesh_offset)
|
||||
laser_ember.emission_box_extents.z = (max_dist - abs(mesh_offset)) / 2.0
|
||||
laser_ember.emission_box_extents.z = (max_dist - absf(mesh_offset)) / 2.0
|
||||
if not col.is_empty():
|
||||
var blast = blast_scene.instantiate()
|
||||
get_tree().get_root().add_child(blast)
|
||||
blast.global_transform.origin = col.position
|
||||
if col.collider == player and player is Player:
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
player.add_camera_shake_trauma(13)
|
||||
player.add_camera_shake_trauma(13.0)
|
||||
|
||||
|
||||
func animate(delta:=0.0):
|
||||
func animate(delta: float) -> void:
|
||||
if state == State.APPROACH:
|
||||
var to_player_local = target_position * global_transform
|
||||
var to_player_local: Vector3 = target_position * global_transform
|
||||
# The front of the robot is +Z, and atan2 is zero at +X, so we need to use the Z for the X parameter (second one).
|
||||
var angle_to_player = atan2(to_player_local.x, to_player_local.z)
|
||||
var angle_to_player: float = atan2(to_player_local.x, to_player_local.z)
|
||||
if angle_to_player > PLAYER_AIM_TOLERANCE_DEGREES:
|
||||
animation_tree["parameters/state/transition_request"] = "turn_left"
|
||||
elif angle_to_player < -PLAYER_AIM_TOLERANCE_DEGREES:
|
||||
@@ -150,22 +151,22 @@ func animate(delta:=0.0):
|
||||
if target_position != Vector3.ZERO:
|
||||
animation_tree["parameters/aiming/blend_amount"] = clamp(aim_preparing / AIM_PREPARE_TIME, 0, 1)
|
||||
|
||||
var to_cannon_local = (target_position + Vector3.UP) * ray_mesh.global_transform
|
||||
var h_angle = rad_to_deg(atan2( to_cannon_local.x, -to_cannon_local.z ))
|
||||
var v_angle = rad_to_deg(atan2( to_cannon_local.y, -to_cannon_local.z ))
|
||||
var blend_pos = animation_tree.get("parameters/aim/blend_position")
|
||||
var h_motion = BLEND_AIM_SPEED * delta * -h_angle
|
||||
var to_cannon_local: Vector3 = (target_position + Vector3.UP) * ray_mesh.global_transform
|
||||
var h_angle: float = rad_to_deg(atan2( to_cannon_local.x, -to_cannon_local.z))
|
||||
var v_angle: float = rad_to_deg(atan2( to_cannon_local.y, -to_cannon_local.z))
|
||||
var blend_pos: Vector2 = animation_tree.get("parameters/aim/blend_position")
|
||||
var h_motion: float = BLEND_AIM_SPEED * delta * -h_angle
|
||||
blend_pos.x += h_motion
|
||||
blend_pos.x = clamp(blend_pos.x, -1, 1)
|
||||
blend_pos.x = clampf(blend_pos.x, -1.0, 1.0)
|
||||
|
||||
var v_motion = BLEND_AIM_SPEED * delta * v_angle
|
||||
var v_motion: float = BLEND_AIM_SPEED * delta * v_angle
|
||||
blend_pos.y += v_motion
|
||||
blend_pos.y = clamp(blend_pos.y, -1, 1)
|
||||
blend_pos.y = clampf(blend_pos.y, -1.0, 1.0)
|
||||
|
||||
animation_tree["parameters/aim/blend_position"] = blend_pos
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
func _physics_process(delta: float) -> void:
|
||||
if dead:
|
||||
return
|
||||
|
||||
@@ -180,7 +181,7 @@ func _physics_process(delta):
|
||||
if not player:
|
||||
target_position = Vector3()
|
||||
animate(delta)
|
||||
set_velocity(gravity * delta)
|
||||
set_velocity(get_gravity() * delta)
|
||||
set_up_direction(Vector3.UP)
|
||||
move_and_slide()
|
||||
return
|
||||
@@ -193,13 +194,13 @@ func _physics_process(delta):
|
||||
if aim_preparing < 0:
|
||||
aim_preparing = 0
|
||||
|
||||
var to_player_local = target_position * global_transform
|
||||
var to_player_local: Vector3 = target_position * global_transform
|
||||
# The front of the robot is +Z, and atan2 is zero at +X, so we need to use the Z for the X parameter (second one).
|
||||
var angle_to_player = atan2(to_player_local.x, to_player_local.z)
|
||||
var angle_to_player: float = atan2(to_player_local.x, to_player_local.z)
|
||||
if angle_to_player > -PLAYER_AIM_TOLERANCE_DEGREES and angle_to_player < PLAYER_AIM_TOLERANCE_DEGREES:
|
||||
# Facing player, try to shoot.
|
||||
shoot_countdown -= delta
|
||||
if shoot_countdown < 0:
|
||||
if shoot_countdown < 0.0:
|
||||
# See if player can be killed because in they're sight.
|
||||
var ray_origin = ray_from.global_transform.origin
|
||||
var ray_to = player.global_transform.origin + Vector3.UP # Above middle of player.
|
||||
@@ -208,13 +209,13 @@ func _physics_process(delta):
|
||||
if not col.is_empty() and col.collider == player:
|
||||
state = State.AIM
|
||||
aim_countdown = AIM_TIME
|
||||
aim_preparing = 0
|
||||
aim_preparing = 0.0
|
||||
else:
|
||||
# Player not in sight, do nothing.
|
||||
shoot_countdown = SHOOT_WAIT
|
||||
|
||||
elif state == State.AIM or state == State.SHOOTING:
|
||||
var max_dist = 1000
|
||||
var max_dist: float = 1000.0
|
||||
if laser_raycast.is_colliding():
|
||||
max_dist = (ray_from.global_transform.origin - laser_raycast.get_collision_point()).length()
|
||||
_clip_ray(max_dist)
|
||||
@@ -224,10 +225,10 @@ func _physics_process(delta):
|
||||
aim_preparing = AIM_PREPARE_TIME
|
||||
|
||||
aim_countdown -= delta
|
||||
if aim_countdown < 0 and state == State.AIM:
|
||||
var ray_origin = ray_from.global_transform.origin
|
||||
var ray_to = target_position + Vector3.UP
|
||||
var col = get_world_3d().direct_space_state.intersect_ray(PhysicsRayQueryParameters3D.create(ray_origin, ray_to, 0xFFFFFFFF, [self]))
|
||||
if aim_countdown < 0.0 and state == State.AIM:
|
||||
var ray_origin: Vector3 = ray_from.global_transform.origin
|
||||
var ray_to: Vector3 = target_position + Vector3.UP
|
||||
var col: Dictionary = get_world_3d().direct_space_state.intersect_ray(PhysicsRayQueryParameters3D.create(ray_origin, ray_to, 0xFFFFFFFF, [self]))
|
||||
if not col.is_empty() and col.collider == player:
|
||||
state = State.SHOOTING
|
||||
shoot_countdown = SHOOT_WAIT
|
||||
@@ -239,10 +240,10 @@ func _physics_process(delta):
|
||||
# Apply root motion to orientation.
|
||||
orientation *= Transform3D(animation_tree.get_root_motion_rotation(), animation_tree.get_root_motion_position())
|
||||
|
||||
var h_velocity = orientation.origin / delta
|
||||
var h_velocity: Vector3 = orientation.origin / delta
|
||||
velocity.x = h_velocity.x
|
||||
velocity.z = h_velocity.z
|
||||
velocity += gravity * delta
|
||||
velocity += get_gravity() * delta
|
||||
set_velocity(velocity)
|
||||
set_up_direction(Vector3.UP)
|
||||
move_and_slide()
|
||||
@@ -254,25 +255,25 @@ func _physics_process(delta):
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func play_shoot():
|
||||
shoot_animation.play("shoot")
|
||||
func play_shoot() -> void:
|
||||
shoot_animation.play(&"shoot")
|
||||
|
||||
|
||||
func shoot_check():
|
||||
func shoot_check() -> void:
|
||||
test_shoot = true
|
||||
|
||||
|
||||
func _clip_ray(length):
|
||||
var mesh_offset = ray_mesh.position.z
|
||||
func _clip_ray(length: float) -> void:
|
||||
var mesh_offset: float = ray_mesh.position.z
|
||||
if not OS.has_feature("dedicated_server"):
|
||||
ray_mesh.get_surface_override_material(0).set_shader_parameter("clip", length + mesh_offset)
|
||||
|
||||
|
||||
func _on_area_body_entered(body):
|
||||
func _on_area_body_entered(body: Node3D) -> void:
|
||||
if body is Player or body.name == "Target":
|
||||
player = body
|
||||
|
||||
|
||||
func _on_area_body_exited(body):
|
||||
func _on_area_body_exited(body: Node3D) -> void:
|
||||
if body is Player:
|
||||
player = null
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://cp4djbb113s3h" path="res://enemies/red_robot/laser/LaserBodyNoise.tres" id="7_dlm32"]
|
||||
[ext_resource type="Material" uid="uid://b2atvw0yire0x" path="res://enemies/red_robot/laser/EmberTrailCutoff.tres" id="7_nxdkr"]
|
||||
[ext_resource type="Material" uid="uid://b0yi1uf4xb6ex" path="res://enemies/red_robot/parts/sparks_effect/SparkMaterial.tres" id="8"]
|
||||
[ext_resource type="Gradient" path="res://enemies/red_robot/laser/EmbersColorOverLife.tres" id="8_8q6ei"]
|
||||
[ext_resource type="Gradient" uid="uid://sqhcvf58y6wj" path="res://enemies/red_robot/laser/EmbersColorOverLife.tres" id="8_8q6ei"]
|
||||
[ext_resource type="AudioStream" uid="uid://bfewuxtmeylhc" path="res://enemies/red_robot/audio/charge.wav" id="9"]
|
||||
[ext_resource type="Material" uid="uid://cqxcjajjrcqvk" path="res://enemies/red_robot/laser/LaserCenter.material" id="9_2boaq"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://bcvohx7obe6ar" path="res://enemies/red_robot/laser/BarrelSmoke_Plane.mesh" id="9_l7o07"]
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
extends Label
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("toggle_debug"):
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if Input.is_action_just_pressed(&"toggle_debug"):
|
||||
visible = not visible
|
||||
|
||||
text = "FPS: " + str(Engine.get_frames_per_second())
|
||||
text += "\nVSync: " + ("Enabled" if DisplayServer.window_get_vsync_mode() else "Disabled")
|
||||
text += "\nMemory: " + "%3.2f" % (OS.get_static_memory_usage() / 1048576.0) + " MiB"
|
||||
|
||||
var online := not multiplayer.multiplayer_peer is OfflineMultiplayerPeer
|
||||
var online: bool = not multiplayer.multiplayer_peer is OfflineMultiplayerPeer
|
||||
text += "\nOnline: " + ("Yes" if online else "No")
|
||||
if online:
|
||||
text += "\nMultiplayer ID: " + str(multiplayer.get_unique_id())
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var spot_light = $SpotLight3D
|
||||
|
||||
func _ready():
|
||||
@onready var spot_light: SpotLight3D = $SpotLight3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if not Settings.config_file.get_value("rendering", "shadow_mapping"):
|
||||
spot_light.shadow_enabled = false
|
||||
|
||||
# Randomize the forklift model.
|
||||
# We have 3 models, may as well use them.
|
||||
randomize()
|
||||
var children = get_child(0).get_children()
|
||||
var child_count = children.size()
|
||||
var which_enabled = floor(randf() * child_count)
|
||||
var children: Array[Node] = get_child(0).get_children()
|
||||
var child_count: int = children.size()
|
||||
var which_enabled: int = floori(randf() * float(child_count))
|
||||
for i in range(child_count):
|
||||
children[i].visible = i == which_enabled
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
extends Node3D
|
||||
|
||||
const RedRobot = preload("res://enemies/red_robot/red_robot.tscn")
|
||||
const PlayerScene = preload("res://player/player.tscn")
|
||||
var lightmap_gi = null
|
||||
|
||||
signal quit
|
||||
#warning-ignore:unused_signal
|
||||
signal replace_main_scene # Useless, but needed as there is no clean way to check if a node exposes a signal
|
||||
|
||||
@onready var world_environment = $WorldEnvironment
|
||||
@onready var robot_spawn_points = $RobotSpawnpoints
|
||||
@onready var player_spawn_points = $PlayerSpawnpoints
|
||||
@onready var spawn_node = $SpawnedNodes
|
||||
const RedRobot: PackedScene = preload("res://enemies/red_robot/red_robot.tscn")
|
||||
const PlayerScene: PackedScene = preload("res://player/player.tscn")
|
||||
|
||||
func _ready():
|
||||
var lightmap_gi: LightmapGI = null
|
||||
|
||||
@onready var world_environment: WorldEnvironment = $WorldEnvironment
|
||||
@onready var robot_spawn_points: Node3D = $RobotSpawnpoints
|
||||
@onready var player_spawn_points: Node3D = $PlayerSpawnpoints
|
||||
@onready var spawned_nodes: Node3D = $SpawnedNodes
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Settings.apply_graphics_settings(get_window(), world_environment.environment, self)
|
||||
|
||||
if Settings.config_file.get_value("rendering", "gi_type") == Settings.GIType.SDFGI:
|
||||
@@ -25,8 +26,8 @@ func _ready():
|
||||
|
||||
if multiplayer.is_server():
|
||||
# Server will spawn the red robots
|
||||
for c in robot_spawn_points.get_children():
|
||||
spawn_robot(c)
|
||||
for child in robot_spawn_points.get_children():
|
||||
spawn_robot(child)
|
||||
|
||||
# Then spawn already connected players at random location
|
||||
randomize()
|
||||
@@ -41,13 +42,13 @@ func _ready():
|
||||
multiplayer.peer_disconnected.connect(del_player)
|
||||
|
||||
|
||||
func setup_sdfgi():
|
||||
func setup_sdfgi() -> void:
|
||||
world_environment.environment.sdfgi_enabled = true
|
||||
$VoxelGI.hide()
|
||||
$ReflectionProbes.hide()
|
||||
# LightmapGI nodes override SDFGI (even when hidden)
|
||||
# so we need to free the LightmapGI node if it exists
|
||||
if (lightmap_gi != null):
|
||||
if lightmap_gi != null:
|
||||
lightmap_gi.queue_free()
|
||||
|
||||
if Settings.config_file.get_value("rendering", "gi_quality") == Settings.GIQuality.HIGH:
|
||||
@@ -58,13 +59,13 @@ func setup_sdfgi():
|
||||
world_environment.environment.sdfgi_enabled = false
|
||||
|
||||
|
||||
func setup_voxelgi():
|
||||
func setup_voxelgi() -> void:
|
||||
world_environment.environment.sdfgi_enabled = false
|
||||
$VoxelGI.show()
|
||||
$ReflectionProbes.hide()
|
||||
# LightmapGI nodes override VoxelGI (even when hidden)
|
||||
# so we need to free the LightmapGI node if it exists
|
||||
if (lightmap_gi != null):
|
||||
if lightmap_gi != null:
|
||||
lightmap_gi.queue_free()
|
||||
|
||||
if Settings.config_file.get_value("rendering", "gi_quality") == Settings.GIQuality.HIGH:
|
||||
@@ -75,13 +76,13 @@ func setup_voxelgi():
|
||||
$VoxelGI.hide()
|
||||
|
||||
|
||||
func setup_lightmapgi():
|
||||
func setup_lightmapgi() -> void:
|
||||
world_environment.environment.sdfgi_enabled = false
|
||||
$VoxelGI.hide()
|
||||
$ReflectionProbes.show()
|
||||
# If no LightmapGI node, create one
|
||||
if (lightmap_gi == null):
|
||||
var new_gi = LightmapGI.new()
|
||||
if lightmap_gi == null:
|
||||
var new_gi := LightmapGI.new()
|
||||
new_gi.light_data = load("res://level/level.lmbake")
|
||||
new_gi.name = "LightmapGI"
|
||||
lightmap_gi = new_gi
|
||||
@@ -92,35 +93,35 @@ func setup_lightmapgi():
|
||||
$ReflectionProbes.hide()
|
||||
|
||||
|
||||
func spawn_robot(spawn_point):
|
||||
var robot = RedRobot.instantiate()
|
||||
func spawn_robot(spawn_point) -> void:
|
||||
var robot: CharacterBody3D = RedRobot.instantiate()
|
||||
robot.transform = spawn_point.transform
|
||||
robot.exploded.connect(_respawn_robot.bind(spawn_point))
|
||||
spawn_node.add_child(robot, true)
|
||||
spawned_nodes.add_child(robot, true)
|
||||
|
||||
|
||||
func _respawn_robot(spawn_point):
|
||||
func _respawn_robot(spawn_point) -> void:
|
||||
await get_tree().create_timer(15.0).timeout
|
||||
spawn_robot(spawn_point)
|
||||
|
||||
|
||||
func del_player(id: int):
|
||||
if not spawn_node.has_node(str(id)):
|
||||
func del_player(id: int) -> void:
|
||||
if not spawned_nodes.has_node(str(id)):
|
||||
return
|
||||
spawn_node.get_node(str(id)).queue_free()
|
||||
spawned_nodes.get_node(str(id)).queue_free()
|
||||
|
||||
|
||||
func add_player(id: int, spawn_point: Marker3D = null):
|
||||
func add_player(id: int, spawn_point: Marker3D = null) -> void:
|
||||
if spawn_point == null:
|
||||
spawn_point = player_spawn_points.get_child(randi() % player_spawn_points.get_child_count())
|
||||
var player = PlayerScene.instantiate()
|
||||
var player: CharacterBody3D = PlayerScene.instantiate()
|
||||
player.name = str(id)
|
||||
player.player_id = id
|
||||
player.transform = spawn_point.transform
|
||||
spawn_node.add_child(player)
|
||||
spawned_nodes.add_child(player)
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("quit"):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"quit"):
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
emit_signal("quit")
|
||||
quit.emit()
|
||||
|
||||
25
main/main.gd
25
main/main.gd
@@ -1,6 +1,7 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
|
||||
func _ready() -> void:
|
||||
multiplayer.server_relay = false
|
||||
if DisplayServer.get_name() == "headless":
|
||||
Engine.max_fps = 60
|
||||
@@ -9,24 +10,24 @@ func _ready():
|
||||
go_to_main_menu()
|
||||
|
||||
|
||||
func go_to_main_menu():
|
||||
var menu = ResourceLoader.load("res://menu/menu.tscn")
|
||||
func go_to_main_menu() -> void:
|
||||
var menu: PackedScene = ResourceLoader.load("res://menu/menu.tscn")
|
||||
multiplayer.multiplayer_peer.close()
|
||||
multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()
|
||||
change_scene_to_file(menu)
|
||||
change_scene_to_packed(menu)
|
||||
|
||||
|
||||
func replace_main_scene(resource):
|
||||
call_deferred("change_scene_to_file", resource)
|
||||
func replace_main_scene(resource: PackedScene) -> void:
|
||||
call_deferred("change_scene_to_packed", resource)
|
||||
|
||||
|
||||
func change_scene_to_file(resource : Resource):
|
||||
var node = resource.instantiate()
|
||||
|
||||
func change_scene_to_packed(resource: PackedScene) -> void:
|
||||
var node: Node = resource.instantiate()
|
||||
for child in get_children():
|
||||
remove_child(child)
|
||||
child.queue_free()
|
||||
add_child(node)
|
||||
|
||||
node.connect("quit",Callable(self,"go_to_main_menu"))
|
||||
node.connect("replace_main_scene",Callable(self,"replace_main_scene"))
|
||||
if node.has_signal(&"quit"):
|
||||
node.quit.connect(go_to_main_menu)
|
||||
if node.has_signal(&"replace_main_scene"):
|
||||
node.replace_main_scene.connect(replace_main_scene)
|
||||
|
||||
220
menu/menu.gd
220
menu/menu.gd
@@ -1,116 +1,119 @@
|
||||
extends Node
|
||||
|
||||
var path = "res://level/level.tscn"
|
||||
|
||||
signal replace_main_scene
|
||||
#warning-ignore:unused_signal
|
||||
signal quit # Useless, but needed as there is no clean way to check if a node exposes a signal
|
||||
|
||||
var peer : MultiplayerPeer = OfflineMultiplayerPeer.new()
|
||||
const LEVEL_PATH: String = "res://level/level.tscn"
|
||||
|
||||
var peer: MultiplayerPeer = OfflineMultiplayerPeer.new()
|
||||
|
||||
var metalfx_supported: bool = RenderingServer.get_current_rendering_driver_name() == "metal"
|
||||
|
||||
@onready var world_environment = $WorldEnvironment
|
||||
@onready var world_environment: WorldEnvironment = $WorldEnvironment
|
||||
|
||||
@onready var ui = $UI
|
||||
@onready var main = ui.get_node("Main")
|
||||
@onready var online = ui.get_node("Online")
|
||||
@onready var play_button = main.get_node("Play")
|
||||
@onready var settings_button = main.get_node("Settings")
|
||||
@onready var quit_button = main.get_node("Quit")
|
||||
@onready var ui: Control = $UI
|
||||
@onready var main: Control = ui.get_node(^"Main")
|
||||
@onready var play_button: Button = main.get_node(^"Play")
|
||||
@onready var settings_button: Button = main.get_node(^"Settings")
|
||||
@onready var quit_button: Button = main.get_node(^"Quit")
|
||||
|
||||
@onready var settings_menu = ui.get_node("Settings")
|
||||
@onready var settings_actions = settings_menu.get_node("Actions")
|
||||
@onready var settings_action_apply = settings_actions.get_node("Apply")
|
||||
@onready var settings_action_cancel = settings_actions.get_node("Cancel")
|
||||
@onready var online: Control = ui.get_node(^"Online")
|
||||
@onready var online_port: SpinBox = online.get_node(^"Port")
|
||||
@onready var online_address: LineEdit = online.get_node(^"Address")
|
||||
|
||||
@onready var display_mode_menu = settings_menu.get_node("DisplayMode")
|
||||
@onready var display_mode_windowed = display_mode_menu.get_node("Windowed")
|
||||
@onready var display_mode_fullscreen = display_mode_menu.get_node("Fullscreen")
|
||||
@onready var display_mode_exclusive_fullscreen = display_mode_menu.get_node("ExclusiveFullscreen")
|
||||
@onready var settings_menu: VBoxContainer = ui.get_node(^"Settings")
|
||||
@onready var settings_actions: HBoxContainer = settings_menu.get_node(^"Actions")
|
||||
@onready var settings_action_apply: Button = settings_actions.get_node(^"Apply")
|
||||
@onready var settings_action_cancel: Button = settings_actions.get_node(^"Cancel")
|
||||
|
||||
@onready var vsync_menu = settings_menu.get_node("VSync")
|
||||
@onready var vsync_disabled = vsync_menu.get_node("Disabled")
|
||||
@onready var vsync_enabled = vsync_menu.get_node("Enabled")
|
||||
@onready var vsync_adaptive = vsync_menu.get_node("Adaptive")
|
||||
@onready var vsync_mailbox = vsync_menu.get_node("Mailbox")
|
||||
@onready var display_mode_menu: HBoxContainer = settings_menu.get_node(^"DisplayMode")
|
||||
@onready var display_mode_windowed: Button = display_mode_menu.get_node(^"Windowed")
|
||||
@onready var display_mode_fullscreen: Button = display_mode_menu.get_node(^"Fullscreen")
|
||||
@onready var display_mode_exclusive_fullscreen: Button = display_mode_menu.get_node(^"ExclusiveFullscreen")
|
||||
|
||||
@onready var max_fps_menu = settings_menu.get_node("MaxFPS")
|
||||
@onready var max_fps_30 = max_fps_menu.get_node("30")
|
||||
@onready var max_fps_40 = max_fps_menu.get_node("40")
|
||||
@onready var max_fps_60 = max_fps_menu.get_node("60")
|
||||
@onready var max_fps_72 = max_fps_menu.get_node("72")
|
||||
@onready var max_fps_90 = max_fps_menu.get_node("90")
|
||||
@onready var max_fps_120 = max_fps_menu.get_node("120")
|
||||
@onready var max_fps_144 = max_fps_menu.get_node("144")
|
||||
@onready var max_fps_unlimited = max_fps_menu.get_node("Unlimited")
|
||||
@onready var vsync_menu: HBoxContainer = settings_menu.get_node(^"VSync")
|
||||
@onready var vsync_disabled: Button = vsync_menu.get_node(^"Disabled")
|
||||
@onready var vsync_enabled: Button = vsync_menu.get_node(^"Enabled")
|
||||
@onready var vsync_adaptive: Button = vsync_menu.get_node(^"Adaptive")
|
||||
@onready var vsync_mailbox: Button = vsync_menu.get_node(^"Mailbox")
|
||||
|
||||
@onready var resolution_scale_menu = settings_menu.get_node("ResolutionScale")
|
||||
@onready var resolution_scale_ultra_performance = resolution_scale_menu.get_node("UltraPerformance")
|
||||
@onready var resolution_scale_performance = resolution_scale_menu.get_node("Performance")
|
||||
@onready var resolution_scale_balanced = resolution_scale_menu.get_node("Balanced")
|
||||
@onready var resolution_scale_quality = resolution_scale_menu.get_node("Quality")
|
||||
@onready var resolution_scale_ultra_quality = resolution_scale_menu.get_node("UltraQuality")
|
||||
@onready var resolution_scale_native = resolution_scale_menu.get_node("Native")
|
||||
@onready var max_fps_menu: HBoxContainer = settings_menu.get_node(^"MaxFPS")
|
||||
@onready var max_fps_30: Button = max_fps_menu.get_node(^"30")
|
||||
@onready var max_fps_40: Button = max_fps_menu.get_node(^"40")
|
||||
@onready var max_fps_60: Button = max_fps_menu.get_node(^"60")
|
||||
@onready var max_fps_72: Button = max_fps_menu.get_node(^"72")
|
||||
@onready var max_fps_90: Button = max_fps_menu.get_node(^"90")
|
||||
@onready var max_fps_120: Button = max_fps_menu.get_node(^"120")
|
||||
@onready var max_fps_144: Button = max_fps_menu.get_node(^"144")
|
||||
@onready var max_fps_unlimited: Button = max_fps_menu.get_node(^"Unlimited")
|
||||
|
||||
@onready var scale_filter_menu = settings_menu.get_node("ScaleFilter")
|
||||
@onready var scale_filter_bilinear = scale_filter_menu.get_node("Bilinear")
|
||||
@onready var scale_filter_fsr1 = scale_filter_menu.get_node("FSR1")
|
||||
@onready var scale_filter_metalfx_spatial = scale_filter_menu.get_node("MetalFXSpatial")
|
||||
@onready var scale_filter_fsr2 = scale_filter_menu.get_node("FSR2")
|
||||
@onready var scale_filter_metalfx_temporal = scale_filter_menu.get_node("MetalFXTemporal")
|
||||
@onready var resolution_scale_menu: HBoxContainer = settings_menu.get_node(^"ResolutionScale")
|
||||
@onready var resolution_scale_ultra_performance: Button = resolution_scale_menu.get_node(^"UltraPerformance")
|
||||
@onready var resolution_scale_performance: Button = resolution_scale_menu.get_node(^"Performance")
|
||||
@onready var resolution_scale_balanced: Button = resolution_scale_menu.get_node(^"Balanced")
|
||||
@onready var resolution_scale_quality: Button = resolution_scale_menu.get_node(^"Quality")
|
||||
@onready var resolution_scale_ultra_quality: Button = resolution_scale_menu.get_node(^"UltraQuality")
|
||||
@onready var resolution_scale_native: Button = resolution_scale_menu.get_node(^"Native")
|
||||
|
||||
@onready var taa_menu = settings_menu.get_node("TAA")
|
||||
@onready var taa_disabled = taa_menu.get_node("Disabled")
|
||||
@onready var taa_enabled = taa_menu.get_node("Enabled")
|
||||
@onready var scale_filter_menu: HBoxContainer = settings_menu.get_node(^"ScaleFilter")
|
||||
@onready var scale_filter_bilinear: Button = scale_filter_menu.get_node(^"Bilinear")
|
||||
@onready var scale_filter_fsr1: Button = scale_filter_menu.get_node(^"FSR1")
|
||||
@onready var scale_filter_metalfx_spatial: Button = scale_filter_menu.get_node(^"MetalFXSpatial")
|
||||
@onready var scale_filter_fsr2: Button = scale_filter_menu.get_node(^"FSR2")
|
||||
@onready var scale_filter_metalfx_temporal: Button = scale_filter_menu.get_node(^"MetalFXTemporal")
|
||||
|
||||
@onready var msaa_menu = settings_menu.get_node("MSAA")
|
||||
@onready var msaa_disabled = msaa_menu.get_node("Disabled")
|
||||
@onready var msaa_2x = msaa_menu.get_node("2X")
|
||||
@onready var msaa_4x = msaa_menu.get_node("4X")
|
||||
@onready var msaa_8x = msaa_menu.get_node("8X")
|
||||
@onready var taa_menu: HBoxContainer = settings_menu.get_node(^"TAA")
|
||||
@onready var taa_disabled: Button = taa_menu.get_node(^"Disabled")
|
||||
@onready var taa_enabled: Button = taa_menu.get_node(^"Enabled")
|
||||
|
||||
@onready var fxaa_menu = settings_menu.get_node("FXAA")
|
||||
@onready var fxaa_disabled = fxaa_menu.get_node("Disabled")
|
||||
@onready var fxaa_enabled = fxaa_menu.get_node("Enabled")
|
||||
@onready var msaa_menu: HBoxContainer = settings_menu.get_node(^"MSAA")
|
||||
@onready var msaa_disabled: Button = msaa_menu.get_node(^"Disabled")
|
||||
@onready var msaa_2x: Button = msaa_menu.get_node(^"2X")
|
||||
@onready var msaa_4x: Button = msaa_menu.get_node(^"4X")
|
||||
@onready var msaa_8x: Button = msaa_menu.get_node(^"8X")
|
||||
|
||||
@onready var shadow_mapping_menu = settings_menu.get_node("ShadowMapping")
|
||||
@onready var shadow_mapping_disabled = shadow_mapping_menu.get_node("Disabled")
|
||||
@onready var shadow_mapping_enabled = shadow_mapping_menu.get_node("Enabled")
|
||||
@onready var fxaa_menu: HBoxContainer = settings_menu.get_node(^"FXAA")
|
||||
@onready var fxaa_disabled: Button = fxaa_menu.get_node(^"Disabled")
|
||||
@onready var fxaa_enabled: Button = fxaa_menu.get_node(^"Enabled")
|
||||
|
||||
@onready var gi_type_menu = settings_menu.get_node("GIType")
|
||||
@onready var gi_lightmapgi = gi_type_menu.get_node("LightmapGI")
|
||||
@onready var gi_voxelgi = gi_type_menu.get_node("VoxelGI")
|
||||
@onready var gi_sdfgi = gi_type_menu.get_node("SDFGI")
|
||||
@onready var shadow_mapping_menu: HBoxContainer = settings_menu.get_node(^"ShadowMapping")
|
||||
@onready var shadow_mapping_disabled: Button = shadow_mapping_menu.get_node(^"Disabled")
|
||||
@onready var shadow_mapping_enabled: Button = shadow_mapping_menu.get_node(^"Enabled")
|
||||
|
||||
@onready var gi_quality_menu = settings_menu.get_node("GIQuality")
|
||||
@onready var gi_disabled = gi_quality_menu.get_node("Disabled")
|
||||
@onready var gi_low = gi_quality_menu.get_node("Low")
|
||||
@onready var gi_high = gi_quality_menu.get_node("High")
|
||||
@onready var gi_type_menu: HBoxContainer = settings_menu.get_node(^"GIType")
|
||||
@onready var gi_lightmapgi: Button = gi_type_menu.get_node(^"LightmapGI")
|
||||
@onready var gi_voxelgi: Button = gi_type_menu.get_node(^"VoxelGI")
|
||||
@onready var gi_sdfgi: Button = gi_type_menu.get_node(^"SDFGI")
|
||||
|
||||
@onready var ssao_menu = settings_menu.get_node("SSAO")
|
||||
@onready var ssao_disabled = ssao_menu.get_node("Disabled")
|
||||
@onready var ssao_medium = ssao_menu.get_node("Medium")
|
||||
@onready var ssao_high = ssao_menu.get_node("High")
|
||||
@onready var gi_quality_menu: HBoxContainer = settings_menu.get_node(^"GIQuality")
|
||||
@onready var gi_disabled: Button = gi_quality_menu.get_node(^"Disabled")
|
||||
@onready var gi_low: Button = gi_quality_menu.get_node(^"Low")
|
||||
@onready var gi_high: Button = gi_quality_menu.get_node(^"High")
|
||||
|
||||
@onready var ssil_menu = settings_menu.get_node("SSIL")
|
||||
@onready var ssil_disabled = ssil_menu.get_node("Disabled")
|
||||
@onready var ssil_medium = ssil_menu.get_node("Medium")
|
||||
@onready var ssil_high = ssil_menu.get_node("High")
|
||||
@onready var ssao_menu: HBoxContainer = settings_menu.get_node(^"SSAO")
|
||||
@onready var ssao_disabled: Button = ssao_menu.get_node(^"Disabled")
|
||||
@onready var ssao_medium: Button = ssao_menu.get_node(^"Medium")
|
||||
@onready var ssao_high: Button = ssao_menu.get_node(^"High")
|
||||
|
||||
@onready var bloom_menu = settings_menu.get_node("Bloom")
|
||||
@onready var bloom_disabled = bloom_menu.get_node("Disabled")
|
||||
@onready var bloom_enabled = bloom_menu.get_node("Enabled")
|
||||
@onready var ssil_menu: HBoxContainer = settings_menu.get_node(^"SSIL")
|
||||
@onready var ssil_disabled: Button = ssil_menu.get_node(^"Disabled")
|
||||
@onready var ssil_medium: Button = ssil_menu.get_node(^"Medium")
|
||||
@onready var ssil_high: Button = ssil_menu.get_node(^"High")
|
||||
|
||||
@onready var volumetric_fog_menu = settings_menu.get_node("VolumetricFog")
|
||||
@onready var volumetric_fog_disabled = volumetric_fog_menu.get_node("Disabled")
|
||||
@onready var volumetric_fog_enabled = volumetric_fog_menu.get_node("Enabled")
|
||||
@onready var bloom_menu: HBoxContainer = settings_menu.get_node(^"Bloom")
|
||||
@onready var bloom_disabled: Button = bloom_menu.get_node(^"Disabled")
|
||||
@onready var bloom_enabled: Button = bloom_menu.get_node(^"Enabled")
|
||||
|
||||
@onready var loading = ui.get_node("Loading")
|
||||
@onready var loading_progress = loading.get_node("Progress")
|
||||
@onready var loading_done_timer = loading.get_node("DoneTimer")
|
||||
@onready var volumetric_fog_menu: HBoxContainer = settings_menu.get_node(^"VolumetricFog")
|
||||
@onready var volumetric_fog_disabled: Button = volumetric_fog_menu.get_node(^"Disabled")
|
||||
@onready var volumetric_fog_enabled: Button = volumetric_fog_menu.get_node(^"Enabled")
|
||||
|
||||
func _ready():
|
||||
@onready var loading: HBoxContainer = ui.get_node(^"Loading")
|
||||
@onready var loading_progress: ProgressBar = loading.get_node(^"Progress")
|
||||
@onready var loading_done_timer: Timer = loading.get_node(^"DoneTimer")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Apply relevant settings directly.
|
||||
Settings.apply_graphics_settings(get_window(), world_environment.environment, self)
|
||||
|
||||
@@ -130,14 +133,15 @@ func _ready():
|
||||
]:
|
||||
_make_button_group(menu)
|
||||
|
||||
func _process(_delta):
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if loading.visible:
|
||||
var progress = []
|
||||
var status = ResourceLoader.load_threaded_get_status(path, progress)
|
||||
var progress: Array = []
|
||||
var status: ResourceLoader.ThreadLoadStatus = ResourceLoader.load_threaded_get_status(LEVEL_PATH, progress)
|
||||
if status == ResourceLoader.THREAD_LOAD_IN_PROGRESS:
|
||||
loading_progress.value = progress[0] * 100
|
||||
loading_progress.value = progress[0] * 100.0
|
||||
elif status == ResourceLoader.THREAD_LOAD_LOADED:
|
||||
loading_progress.value = 100
|
||||
loading_progress.value = 100.0
|
||||
set_process(false)
|
||||
loading_done_timer.start()
|
||||
else:
|
||||
@@ -145,23 +149,27 @@ func _process(_delta):
|
||||
main.show()
|
||||
loading.hide()
|
||||
|
||||
func _make_button_group(common_parent: Node):
|
||||
|
||||
func _make_button_group(common_parent: Node) -> void:
|
||||
var group = ButtonGroup.new()
|
||||
for btn in common_parent.get_children():
|
||||
if not btn is BaseButton:
|
||||
continue
|
||||
btn.button_group = group
|
||||
|
||||
func _on_loading_done_timer_timeout():
|
||||
multiplayer.multiplayer_peer = peer
|
||||
emit_signal("replace_main_scene", ResourceLoader.load_threaded_get(path))
|
||||
|
||||
func _on_play_pressed():
|
||||
func _on_loading_done_timer_timeout() -> void:
|
||||
multiplayer.multiplayer_peer = peer
|
||||
emit_signal("replace_main_scene", ResourceLoader.load_threaded_get(LEVEL_PATH))
|
||||
|
||||
|
||||
func _on_play_pressed() -> void:
|
||||
main.hide()
|
||||
loading.show()
|
||||
ResourceLoader.load_threaded_request(path, "", true)
|
||||
ResourceLoader.load_threaded_request(LEVEL_PATH, "", true)
|
||||
|
||||
func _on_settings_pressed():
|
||||
|
||||
func _on_settings_pressed() -> void:
|
||||
main.hide()
|
||||
settings_menu.show()
|
||||
settings_action_cancel.grab_focus()
|
||||
@@ -294,11 +302,11 @@ func _on_settings_pressed():
|
||||
volumetric_fog_enabled.button_pressed = true
|
||||
|
||||
|
||||
func _on_quit_pressed():
|
||||
func _on_quit_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func _on_apply_pressed():
|
||||
func _on_apply_pressed() -> void:
|
||||
main.show()
|
||||
play_button.grab_focus()
|
||||
settings_menu.hide()
|
||||
@@ -411,27 +419,27 @@ func _on_apply_pressed():
|
||||
Settings.save_settings()
|
||||
|
||||
|
||||
func _on_cancel_pressed():
|
||||
func _on_cancel_pressed() -> void:
|
||||
main.show()
|
||||
play_button.grab_focus()
|
||||
settings_menu.hide()
|
||||
online.hide()
|
||||
|
||||
|
||||
func _on_play_online_pressed():
|
||||
func _on_play_online_pressed() -> void:
|
||||
online.show()
|
||||
main.hide()
|
||||
|
||||
|
||||
func _on_host_pressed():
|
||||
func _on_host_pressed() -> void:
|
||||
peer = ENetMultiplayerPeer.new()
|
||||
peer.create_server(int($UI/Online/Port.value))
|
||||
peer.create_server(int(online_port.value))
|
||||
_on_play_pressed()
|
||||
online.hide()
|
||||
|
||||
|
||||
func _on_connect_pressed():
|
||||
func _on_connect_pressed() -> void:
|
||||
peer = ENetMultiplayerPeer.new()
|
||||
peer.create_client($UI/Online/Address.text, int($UI/Online/Port.value))
|
||||
peer.create_client(online_address.text, int(online_port.value))
|
||||
_on_play_pressed()
|
||||
online.hide()
|
||||
|
||||
@@ -42,17 +42,17 @@ var DEFAULTS := {
|
||||
var config_file := ConfigFile.new()
|
||||
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
load_settings()
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("toggle_fullscreen"):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"toggle_fullscreen"):
|
||||
get_window().mode = Window.MODE_EXCLUSIVE_FULLSCREEN if (!((get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) or (get_window().mode == Window.MODE_FULLSCREEN))) else Window.MODE_WINDOWED
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func load_settings():
|
||||
func load_settings() -> void:
|
||||
config_file.load(CONFIG_FILE_PATH)
|
||||
# Initialize defaults for values not found in the existing configuration file,
|
||||
# so we don't have to specify them every time we use `ConfigFile.get_value()`.
|
||||
@@ -62,11 +62,11 @@ func load_settings():
|
||||
config_file.set_value(section, key, DEFAULTS[section][key])
|
||||
|
||||
|
||||
func save_settings():
|
||||
func save_settings() -> void:
|
||||
config_file.save(CONFIG_FILE_PATH)
|
||||
|
||||
|
||||
func apply_graphics_settings(window: Window, environment: Environment, scene_root: Node):
|
||||
func apply_graphics_settings(window: Window, environment: Environment, scene_root: Node) -> void:
|
||||
get_window().mode = Settings.config_file.get_value("video", "display_mode")
|
||||
DisplayServer.window_set_vsync_mode(Settings.config_file.get_value("video", "vsync"))
|
||||
Engine.max_fps = Settings.config_file.get_value("video", "max_fps")
|
||||
|
||||
@@ -1,31 +1,34 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
const BULLET_VELOCITY = 20
|
||||
|
||||
var time_alive = 5
|
||||
var hit = false
|
||||
const BULLET_VELOCITY: float = 20.0
|
||||
|
||||
@onready var animation_player = $AnimationPlayer
|
||||
@onready var collision_shape = $CollisionShape3D
|
||||
@onready var omni_light = $OmniLight3D
|
||||
var time_alive: float = 5.0
|
||||
var hit: bool = false
|
||||
|
||||
func _ready():
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var collision_shape: CollisionShape3D = $CollisionShape3D
|
||||
@onready var omni_light: OmniLight3D = $OmniLight3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if not multiplayer.is_server():
|
||||
set_physics_process(false)
|
||||
collision_shape.disabled = true
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
func _physics_process(delta: float) -> void:
|
||||
if hit:
|
||||
return
|
||||
time_alive -= delta
|
||||
if time_alive < 0:
|
||||
if time_alive < 0.0:
|
||||
hit = true
|
||||
explode.rpc()
|
||||
var col = move_and_collide(-delta * BULLET_VELOCITY * transform.basis.z)
|
||||
var displacement: Vector3 = -delta * BULLET_VELOCITY * transform.basis.z
|
||||
var col: KinematicCollision3D = move_and_collide(displacement)
|
||||
if col:
|
||||
var collider = col.get_collider()
|
||||
if collider and collider.has_method("hit"):
|
||||
var collider: Node3D = col.get_collider() as Node3D
|
||||
if collider and collider.has_method(&"hit"):
|
||||
collider.hit.rpc()
|
||||
collision_shape.disabled = true
|
||||
explode.rpc()
|
||||
@@ -33,8 +36,8 @@ func _physics_process(delta):
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func explode():
|
||||
animation_player.play("explode")
|
||||
func explode() -> void:
|
||||
animation_player.play(&"explode")
|
||||
|
||||
# Only enable shadows for the explosion, as the moving light
|
||||
# is very small and doesn't noticeably benefit from shadow mapping.
|
||||
@@ -42,7 +45,7 @@ func explode():
|
||||
omni_light.shadow_enabled = true
|
||||
|
||||
|
||||
func destroy():
|
||||
func destroy() -> void:
|
||||
if not multiplayer.is_server():
|
||||
return
|
||||
queue_free()
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
extends Camera3D
|
||||
|
||||
# Constant values of the effect.
|
||||
const SPEED = 1.0
|
||||
const DECAY_RATE = 1.5
|
||||
const MAX_YAW = 0.05
|
||||
const MAX_PITCH = 0.05
|
||||
const MAX_ROLL = 0.1
|
||||
const MAX_TRAUMA = 1.2
|
||||
const SPEED: float = 1.0
|
||||
const DECAY_RATE: float = 1.5
|
||||
const MAX_YAW: float = 0.05
|
||||
const MAX_PITCH: float = 0.05
|
||||
const MAX_ROLL: float = 0.1
|
||||
const MAX_TRAUMA: float = 1.2
|
||||
|
||||
# Default values.
|
||||
var start_rotation = rotation
|
||||
var trauma = 0.0
|
||||
var time = 0.0
|
||||
var noise = FastNoiseLite.new()
|
||||
var noise_seed = randi()
|
||||
var start_rotation: Vector3 = rotation
|
||||
var trauma: float = 0.0
|
||||
var time: float = 0.0
|
||||
var noise := FastNoiseLite.new()
|
||||
var noise_seed: int = randi()
|
||||
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
noise.seed = noise_seed
|
||||
noise.fractal_octaves = 1
|
||||
noise.fractal_lacunarity = 1.0
|
||||
@@ -27,35 +27,35 @@ func _ready():
|
||||
start_rotation = rotation
|
||||
|
||||
|
||||
func _process(delta):
|
||||
func _process(delta: float) -> void:
|
||||
if trauma > 0.0:
|
||||
decay_trauma(delta)
|
||||
apply_shake(delta)
|
||||
|
||||
|
||||
# Add trauma to start/continue the shake.
|
||||
func add_trauma(amount):
|
||||
trauma = min(trauma + amount, MAX_TRAUMA)
|
||||
func add_trauma(amount: float) -> void:
|
||||
trauma = minf(trauma + amount, MAX_TRAUMA)
|
||||
|
||||
|
||||
# Decay the trauma effect over time.
|
||||
func decay_trauma(delta):
|
||||
var change = DECAY_RATE * delta
|
||||
trauma = max(trauma - change, 0.0)
|
||||
func decay_trauma(delta: float) -> void:
|
||||
var change: float = DECAY_RATE * delta
|
||||
trauma = maxf(trauma - change, 0.0)
|
||||
|
||||
|
||||
# Apply the random shake accoring to delta time.
|
||||
func apply_shake(delta):
|
||||
func apply_shake(delta: float) -> void:
|
||||
# Using a magic number here to get a pleasing effect at SPEED 1.0.
|
||||
time += delta * SPEED * 5000.0
|
||||
var shake = trauma * trauma
|
||||
var yaw = MAX_YAW * shake * get_noise_value(noise_seed, time)
|
||||
var pitch = MAX_PITCH * shake * get_noise_value(noise_seed + 1, time)
|
||||
var roll = MAX_ROLL * shake * get_noise_value(noise_seed + 2, time)
|
||||
var shake: float = trauma * trauma
|
||||
var yaw: float = MAX_YAW * shake * get_noise_value(noise_seed, time)
|
||||
var pitch: float = MAX_PITCH * shake * get_noise_value(noise_seed + 1, time)
|
||||
var roll: float = MAX_ROLL * shake * get_noise_value(noise_seed + 2, time)
|
||||
rotation = start_rotation + Vector3(pitch, yaw, roll)
|
||||
|
||||
|
||||
# Return a random float in range(-1, 1) using OpenSimplex noise.
|
||||
func get_noise_value(seed_value, t):
|
||||
func get_noise_value(seed_value: int, pos: float) -> float:
|
||||
noise.seed = seed_value
|
||||
return noise.get_noise_1d(t)
|
||||
return noise.get_noise_1d(pos)
|
||||
|
||||
129
player/player.gd
129
player/player.gd
@@ -1,44 +1,49 @@
|
||||
class_name Player
|
||||
extends CharacterBody3D
|
||||
|
||||
enum ANIMATIONS {JUMP_UP, JUMP_DOWN, STRAFE, WALK}
|
||||
|
||||
const DIRECTION_INTERPOLATE_SPEED = 1
|
||||
const MOTION_INTERPOLATE_SPEED = 10
|
||||
const ROTATION_INTERPOLATE_SPEED = 10
|
||||
enum Animations {
|
||||
JUMP_UP,
|
||||
JUMP_DOWN,
|
||||
STRAFE,
|
||||
WALK,
|
||||
}
|
||||
|
||||
const MIN_AIRBORNE_TIME = 0.1
|
||||
const JUMP_SPEED = 5
|
||||
const MOTION_INTERPOLATE_SPEED: float = 10.0
|
||||
const ROTATION_INTERPOLATE_SPEED: float = 10.0
|
||||
|
||||
var airborne_time = 100
|
||||
const MIN_AIRBORNE_TIME: float = 0.1
|
||||
const JUMP_SPEED: float = 5.0
|
||||
|
||||
var orientation = Transform3D()
|
||||
var root_motion = Transform3D()
|
||||
var motion = Vector2()
|
||||
var airborne_time: float = 100.0
|
||||
|
||||
@onready var initial_position = transform.origin
|
||||
@onready var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
|
||||
var orientation := Transform3D()
|
||||
var root_motion := Transform3D()
|
||||
var motion := Vector2()
|
||||
|
||||
@onready var player_input = $InputSynchronizer
|
||||
@onready var animation_tree = $AnimationTree
|
||||
@onready var player_model = $PlayerModel
|
||||
@onready var shoot_from = player_model.get_node("Robot_Skeleton/Skeleton3D/GunBone/ShootFrom")
|
||||
@onready var crosshair = $Crosshair
|
||||
@onready var fire_cooldown = $FireCooldown
|
||||
@onready var initial_position: Vector3 = transform.origin
|
||||
|
||||
@onready var sound_effects = $SoundEffects
|
||||
@onready var sound_effect_jump = sound_effects.get_node("Jump")
|
||||
@onready var sound_effect_land = sound_effects.get_node("Land")
|
||||
@onready var sound_effect_shoot = sound_effects.get_node("Shoot")
|
||||
@onready var player_input: PlayerInputSynchronizer = $InputSynchronizer
|
||||
@onready var animation_tree: AnimationTree = $AnimationTree
|
||||
@onready var player_model: Node3D = $PlayerModel
|
||||
@onready var shoot_from: Marker3D = player_model.get_node(^"Robot_Skeleton/Skeleton3D/GunBone/ShootFrom")
|
||||
@onready var crosshair: TextureRect = $Crosshair
|
||||
@onready var fire_cooldown: Timer = $FireCooldown
|
||||
|
||||
@export var player_id := 1 :
|
||||
@onready var sound_effects: Node = $SoundEffects
|
||||
@onready var sound_effect_jump: AudioStreamPlayer = sound_effects.get_node(^"Jump")
|
||||
@onready var sound_effect_land: AudioStreamPlayer = sound_effects.get_node(^"Land")
|
||||
@onready var sound_effect_shoot: AudioStreamPlayer = sound_effects.get_node(^"Shoot")
|
||||
|
||||
@export var player_id: int = 1:
|
||||
set(value):
|
||||
player_id = value
|
||||
$InputSynchronizer.set_multiplayer_authority(value)
|
||||
|
||||
@export var current_animation := ANIMATIONS.WALK
|
||||
@export var current_animation := Animations.WALK
|
||||
|
||||
func _ready():
|
||||
|
||||
func _ready() -> void:
|
||||
# Pre-initialize orientation transform.
|
||||
orientation = player_model.global_transform
|
||||
orientation.origin = Vector3()
|
||||
@@ -46,30 +51,30 @@ func _ready():
|
||||
set_process(false)
|
||||
|
||||
|
||||
func _physics_process(delta: float):
|
||||
func _physics_process(delta: float) -> void:
|
||||
if multiplayer.is_server():
|
||||
apply_input(delta)
|
||||
else:
|
||||
animate(current_animation, delta)
|
||||
|
||||
|
||||
func animate(anim: int, delta:=0.0):
|
||||
current_animation = anim
|
||||
func animate(anim: int, _delta: float) -> void:
|
||||
current_animation = anim as Animations
|
||||
|
||||
if anim == ANIMATIONS.JUMP_UP:
|
||||
if anim == Animations.JUMP_UP:
|
||||
animation_tree["parameters/state/transition_request"] = "jump_up"
|
||||
|
||||
elif anim == ANIMATIONS.JUMP_DOWN:
|
||||
elif anim == Animations.JUMP_DOWN:
|
||||
animation_tree["parameters/state/transition_request"] = "jump_down"
|
||||
|
||||
elif anim == ANIMATIONS.STRAFE:
|
||||
elif anim == Animations.STRAFE:
|
||||
animation_tree["parameters/state/transition_request"] = "strafe"
|
||||
# Change aim according to camera rotation.
|
||||
animation_tree["parameters/aim/add_amount"] = player_input.get_aim_rotation()
|
||||
# The animation's forward/backward axis is reversed.
|
||||
animation_tree["parameters/strafe/blend_position"] = Vector2(motion.x, -motion.y)
|
||||
|
||||
elif anim == ANIMATIONS.WALK:
|
||||
elif anim == Animations.WALK:
|
||||
# Aim to zero (no aiming while walking).
|
||||
animation_tree["parameters/aim/add_amount"] = 0
|
||||
# Change state to walk.
|
||||
@@ -78,12 +83,12 @@ func animate(anim: int, delta:=0.0):
|
||||
animation_tree["parameters/walk/blend_position"] = Vector2(motion.length(), 0)
|
||||
|
||||
|
||||
func apply_input(delta: float):
|
||||
func apply_input(delta: float) -> void:
|
||||
motion = motion.lerp(player_input.motion, MOTION_INTERPOLATE_SPEED * delta)
|
||||
|
||||
var camera_basis : Basis = player_input.get_camera_rotation_basis()
|
||||
var camera_z := camera_basis.z
|
||||
var camera_x := camera_basis.x
|
||||
var camera_basis: Basis = player_input.get_camera_rotation_basis()
|
||||
var camera_z: Vector3 = camera_basis.z
|
||||
var camera_x: Vector3 = camera_basis.x
|
||||
|
||||
camera_z.y = 0
|
||||
camera_z = camera_z.normalized()
|
||||
@@ -97,7 +102,7 @@ func apply_input(delta: float):
|
||||
land.rpc()
|
||||
airborne_time = 0
|
||||
|
||||
var on_air = airborne_time > MIN_AIRBORNE_TIME
|
||||
var on_air: bool = airborne_time > MIN_AIRBORNE_TIME
|
||||
|
||||
if not on_air and player_input.jumping:
|
||||
velocity.y = JUMP_SPEED
|
||||
@@ -109,54 +114,54 @@ func apply_input(delta: float):
|
||||
player_input.jumping = false
|
||||
|
||||
if on_air:
|
||||
if (velocity.y > 0):
|
||||
animate(ANIMATIONS.JUMP_UP, delta)
|
||||
if velocity.y > 0:
|
||||
animate(Animations.JUMP_UP, delta)
|
||||
else:
|
||||
animate(ANIMATIONS.JUMP_DOWN, delta)
|
||||
animate(Animations.JUMP_DOWN, delta)
|
||||
elif player_input.aiming:
|
||||
# Convert orientation to quaternions for interpolating rotation.
|
||||
var q_from = orientation.basis.get_rotation_quaternion()
|
||||
var q_to = player_input.get_camera_base_quaternion()
|
||||
var q_from: Quaternion = orientation.basis.get_rotation_quaternion()
|
||||
var q_to: Quaternion = player_input.get_camera_base_quaternion()
|
||||
# Interpolate current rotation with desired one.
|
||||
orientation.basis = Basis(q_from.slerp(q_to, delta * ROTATION_INTERPOLATE_SPEED))
|
||||
|
||||
# Change state to strafe.
|
||||
animate(ANIMATIONS.STRAFE, delta)
|
||||
animate(Animations.STRAFE, delta)
|
||||
|
||||
root_motion = Transform3D(animation_tree.get_root_motion_rotation(), animation_tree.get_root_motion_position())
|
||||
|
||||
if player_input.shooting and fire_cooldown.time_left == 0:
|
||||
var shoot_origin = shoot_from.global_transform.origin
|
||||
var shoot_dir = (player_input.shoot_target - shoot_origin).normalized()
|
||||
var shoot_origin: Vector3 = shoot_from.global_transform.origin
|
||||
var shoot_dir: Vector3 = (player_input.shoot_target - shoot_origin).normalized()
|
||||
|
||||
var bullet = preload("res://player/bullet/bullet.tscn").instantiate()
|
||||
var bullet: CharacterBody3D = preload("res://player/bullet/bullet.tscn").instantiate()
|
||||
get_parent().add_child(bullet, true)
|
||||
bullet.global_transform.origin = shoot_origin
|
||||
# If we don't rotate the bullets there is no useful way to control the particles ..
|
||||
bullet.look_at(shoot_origin + shoot_dir, Vector3.UP)
|
||||
bullet.look_at(shoot_origin + shoot_dir)
|
||||
bullet.add_collision_exception_with(self)
|
||||
shoot.rpc()
|
||||
|
||||
else: # Not in air or aiming, idle.
|
||||
# Convert orientation to quaternions for interpolating rotation.
|
||||
var target = camera_x * motion.x + camera_z * motion.y
|
||||
var target: Vector3 = camera_x * motion.x + camera_z * motion.y
|
||||
if target.length() > 0.001:
|
||||
var q_from = orientation.basis.get_rotation_quaternion()
|
||||
var q_to = Transform3D().looking_at(target, Vector3.UP).basis.get_rotation_quaternion()
|
||||
var q_from: Quaternion = orientation.basis.get_rotation_quaternion()
|
||||
var q_to: Quaternion = Basis.looking_at(target).get_rotation_quaternion()
|
||||
# Interpolate current rotation with desired one.
|
||||
orientation.basis = Basis(q_from.slerp(q_to, delta * ROTATION_INTERPOLATE_SPEED))
|
||||
|
||||
animate(ANIMATIONS.WALK, delta)
|
||||
animate(Animations.WALK, delta)
|
||||
|
||||
root_motion = Transform3D(animation_tree.get_root_motion_rotation(), animation_tree.get_root_motion_position())
|
||||
|
||||
# Apply root motion to orientation.
|
||||
orientation *= root_motion
|
||||
|
||||
var h_velocity = orientation.origin / delta
|
||||
var h_velocity: Vector3 = orientation.origin / delta
|
||||
velocity.x = h_velocity.x
|
||||
velocity.z = h_velocity.z
|
||||
velocity += gravity * delta
|
||||
velocity += get_gravity() * delta
|
||||
set_velocity(velocity)
|
||||
set_up_direction(Vector3.UP)
|
||||
move_and_slide()
|
||||
@@ -167,24 +172,24 @@ func apply_input(delta: float):
|
||||
player_model.global_transform.basis = orientation.basis
|
||||
|
||||
# If we're below -40, respawn (teleport to the initial position).
|
||||
if transform.origin.y < -40:
|
||||
if transform.origin.y < -40.0:
|
||||
transform.origin = initial_position
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func jump():
|
||||
animate(ANIMATIONS.JUMP_UP)
|
||||
func jump() -> void:
|
||||
animate(Animations.JUMP_UP, 0.0)
|
||||
sound_effect_jump.play()
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func land():
|
||||
animate(ANIMATIONS.JUMP_DOWN)
|
||||
func land() -> void:
|
||||
animate(Animations.JUMP_DOWN, 0.0)
|
||||
sound_effect_land.play()
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func shoot():
|
||||
func shoot() -> void:
|
||||
var shoot_particle = $PlayerModel/Robot_Skeleton/Skeleton3D/GunBone/ShootFrom/ShootParticle
|
||||
shoot_particle.restart()
|
||||
shoot_particle.emitting = true
|
||||
@@ -197,10 +202,10 @@ func shoot():
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func hit():
|
||||
add_camera_shake_trauma(.75)
|
||||
func hit() -> void:
|
||||
add_camera_shake_trauma(0.75)
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func add_camera_shake_trauma(amount):
|
||||
func add_camera_shake_trauma(amount: float) -> void:
|
||||
player_input.camera_camera.add_trauma(amount)
|
||||
|
||||
@@ -347,107 +347,107 @@ color_rect = NodePath("../ColorRect")
|
||||
transform = Transform3D(0.803991, 0, 0, 0, 0.803991, 0, 0, 0, 0.803991, 0, 0, 0)
|
||||
|
||||
[node name="Skeleton3D" parent="PlayerModel/Robot_Skeleton" index="0"]
|
||||
bones/1/position = Vector3(0.11434664, 2.2243905, -0.19463673)
|
||||
bones/1/rotation = Quaternion(0.19226672, 0.060088743, -0.0004170333, 0.9795013)
|
||||
bones/2/position = Vector3(1.7939741e-05, 0.23807003, -9.308201e-05)
|
||||
bones/2/rotation = Quaternion(-0.06526891, -0.038561683, 0.007978548, 0.99709046)
|
||||
bones/3/position = Vector3(1.7910073e-05, 0.10140592, -0.00014185024)
|
||||
bones/3/rotation = Quaternion(-0.07390091, -0.039377727, 0.00023682867, 0.9964879)
|
||||
bones/4/position = Vector3(1.7915016e-05, 0.116211005, -0.00018991233)
|
||||
bones/4/rotation = Quaternion(-0.010791556, -0.039007146, -0.005394789, 0.99916613)
|
||||
bones/5/position = Vector3(9.390414e-06, 0.32578516, -0.00010646117)
|
||||
bones/5/rotation = Quaternion(0.18071488, 6.460865e-05, 0.0014225795, 0.9835345)
|
||||
bones/6/rotation = Quaternion(0.031826243, 0.82586175, 0.561754, -0.037039436)
|
||||
bones/7/position = Vector3(-2.6538997e-11, -0.00046025956, -0.010185308)
|
||||
bones/7/rotation = Quaternion(-0.0033466022, 0.70674294, 0.7074283, 0.0069659874)
|
||||
bones/1/position = Vector3(0.113214746, 2.208326, -0.19343172)
|
||||
bones/1/rotation = Quaternion(0.18813437, -0.014960046, -0.0026600193, 0.9820258)
|
||||
bones/2/position = Vector3(1.45639515e-05, 0.24032742, -0.0005784641)
|
||||
bones/2/rotation = Quaternion(-0.05581198, 0.009215775, -0.0038114812, 0.99839157)
|
||||
bones/3/position = Vector3(1.4562347e-05, 0.10371419, -0.00019366841)
|
||||
bones/3/rotation = Quaternion(-0.06438526, 0.009743746, -0.0019340379, 0.9978757)
|
||||
bones/4/position = Vector3(1.4565465e-05, 0.11848075, 0.00023304476)
|
||||
bones/4/rotation = Quaternion(-0.0012221826, 0.009915214, -0.0005185885, 0.99995)
|
||||
bones/5/position = Vector3(-9.847726e-09, 0.326439, -1.6811337e-05)
|
||||
bones/5/rotation = Quaternion(0.18071476, -8.4258245e-05, -0.0018551972, 0.98353386)
|
||||
bones/6/rotation = Quaternion(-0.025575621, 0.85735846, 0.51398593, 0.01004232)
|
||||
bones/7/position = Vector3(-2.8825162e-10, -0.00046027597, -0.011364902)
|
||||
bones/7/rotation = Quaternion(-0.0053191856, 0.70700586, 0.70718396, 0.0023251213)
|
||||
bones/8/rotation = Quaternion(0.9659259, 2.2469582e-08, 1.459032e-07, 0.2588189)
|
||||
bones/9/position = Vector3(-3.65845e-09, 0.2550956, 0.039909024)
|
||||
bones/10/position = Vector3(-1.1328599e-08, 0.24558353, 0.12663132)
|
||||
bones/11/rotation = Quaternion(4.1605387e-07, 0.9305971, 0.36604503, -5.700369e-07)
|
||||
bones/12/rotation = Quaternion(4.1679712e-07, 0.9305971, 0.36604515, -5.694282e-07)
|
||||
bones/13/rotation = Quaternion(0.04429842, 0.95814234, -0.28245717, 0.014792927)
|
||||
bones/14/rotation = Quaternion(2.1057377e-07, 0.95916545, -0.28284588, -7.207658e-07)
|
||||
bones/15/rotation = Quaternion(-0.33938575, -0.36360154, -0.46693462, 0.7311521)
|
||||
bones/16/rotation = Quaternion(-0.6401529, 0.06566458, 0.16986193, 0.74635077)
|
||||
bones/17/rotation = Quaternion(-0.05781147, 0.01860065, -0.37974682, 0.9230949)
|
||||
bones/18/rotation = Quaternion(-0.07014421, 0.005956485, -0.38976333, 0.9182205)
|
||||
bones/10/position = Vector3(-1.5798946e-08, 0.24558353, 0.12663133)
|
||||
bones/11/rotation = Quaternion(4.1615812e-07, 0.9305971, 0.36604506, -5.6989103e-07)
|
||||
bones/12/rotation = Quaternion(4.1676222e-07, 0.9305971, 0.36604518, -5.6955815e-07)
|
||||
bones/13/rotation = Quaternion(0.04429838, 0.95814234, -0.28245717, 0.014792881)
|
||||
bones/14/rotation = Quaternion(2.102921e-07, 0.95916545, -0.28284588, -7.2073624e-07)
|
||||
bones/15/rotation = Quaternion(-0.3280191, -0.35895362, -0.43301874, 0.75898)
|
||||
bones/16/rotation = Quaternion(-0.6796716, 0.068970636, 0.160612, 0.7123858)
|
||||
bones/17/rotation = Quaternion(-0.05349828, 0.008888353, -0.24022713, 0.9692006)
|
||||
bones/18/rotation = Quaternion(-0.06010165, -0.0008459066, -0.24185945, 0.96844786)
|
||||
bones/18/scale = Vector3(0.99999994, 1.0000002, 1.0000001)
|
||||
bones/19/rotation = Quaternion(-0.0007195591, 0.00071102375, 0.99913824, -0.04149408)
|
||||
bones/20/rotation = Quaternion(-0.023837343, -0.012720647, 0.99259996, 0.11838677)
|
||||
bones/20/rotation = Quaternion(-0.025691334, -0.013504442, 0.99146676, 0.12708747)
|
||||
bones/21/rotation = Quaternion(7.364566e-07, 3.8668645e-06, -5.9215157e-08, 1)
|
||||
bones/22/rotation = Quaternion(-0.17170152, -0.03885242, -0.00041137126, 0.98438257)
|
||||
bones/22/rotation = Quaternion(-0.1455926, -0.031913467, -0.00061063183, 0.9888296)
|
||||
bones/22/scale = Vector3(0.9999999, 1, 1.0000002)
|
||||
bones/23/rotation = Quaternion(-0.24634066, -0.020005792, -0.003269778, 0.9689714)
|
||||
bones/24/rotation = Quaternion(-0.34846973, -0.11955427, -0.004711098, 0.9296524)
|
||||
bones/25/rotation = Quaternion(-0.43266764, -0.07142856, -0.022029812, 0.8984494)
|
||||
bones/25/scale = Vector3(0.8756498, 0.8756497, 0.87564987)
|
||||
bones/27/rotation = Quaternion(-0.09541249, 0.09541334, -0.7006424, 0.7006376)
|
||||
bones/28/rotation = Quaternion(8.410347e-05, -0.007995401, 0.45622185, 0.88983023)
|
||||
bones/23/rotation = Quaternion(-0.24192418, -0.020020474, -0.0031786023, 0.9700835)
|
||||
bones/24/rotation = Quaternion(-0.36099058, -0.11947971, -0.0063249255, 0.9248624)
|
||||
bones/25/rotation = Quaternion(-0.41017327, -0.071954705, -0.020245284, 0.9089392)
|
||||
bones/25/scale = Vector3(0.88370746, 0.88370746, 0.8837076)
|
||||
bones/27/rotation = Quaternion(-0.060405422, 0.060406025, -0.7045244, 0.70451945)
|
||||
bones/28/rotation = Quaternion(0.00018453119, -0.0078856675, 0.4941151, 0.86936074)
|
||||
bones/28/scale = Vector3(0.9999945, 1.0000057, 0.99999994)
|
||||
bones/29/rotation = Quaternion(0.0042037284, 0.00610656, 0.13700639, 0.9905425)
|
||||
bones/29/scale = Vector3(1.00001, 0.99999046, 1.0000001)
|
||||
bones/30/rotation = Quaternion(-8.16753e-05, -0.0040786723, 0.51386577, 0.8578609)
|
||||
bones/30/rotation = Quaternion(-0.0002572407, -0.0040713702, 0.5503304, 0.83493704)
|
||||
bones/30/scale = Vector3(1, 1, 1.0000001)
|
||||
bones/32/rotation = Quaternion(7.5486537e-07, 3.871002e-06, 0.006341643, 0.9999799)
|
||||
bones/33/rotation = Quaternion(-0.12836097, -0.021033943, -0.008022752, 0.99147195)
|
||||
bones/33/rotation = Quaternion(-0.113944784, -0.019573553, -0.007905017, 0.9932628)
|
||||
bones/33/scale = Vector3(0.99999994, 0.9999997, 1.0000004)
|
||||
bones/34/rotation = Quaternion(-0.3202466, -0.017944671, -0.0073007913, 0.94713616)
|
||||
bones/34/rotation = Quaternion(-0.29273328, -0.020594185, -0.0043712384, 0.9559624)
|
||||
bones/34/scale = Vector3(0.9999999, 1.0000001, 1.0000004)
|
||||
bones/35/rotation = Quaternion(-0.44117987, -0.118453324, -0.01684121, 0.8894074)
|
||||
bones/36/rotation = Quaternion(-0.46402794, -0.067679755, -0.030094178, 0.88271856)
|
||||
bones/36/scale = Vector3(0.79854316, 0.7985431, 0.7985433)
|
||||
bones/35/rotation = Quaternion(-0.4174415, -0.11885819, -0.013694503, 0.9007929)
|
||||
bones/36/rotation = Quaternion(-0.4294486, -0.06879587, -0.027447043, 0.9000488)
|
||||
bones/36/scale = Vector3(0.83678937, 0.8367893, 0.8367894)
|
||||
bones/38/rotation = Quaternion(7.417665e-07, 3.8722133e-06, -2.7591668e-07, 1)
|
||||
bones/39/rotation = Quaternion(-0.101930395, -0.010897739, -0.0025515554, 0.99472857)
|
||||
bones/40/rotation = Quaternion(-0.3890697, -0.009414208, -0.011520558, 0.9210882)
|
||||
bones/41/rotation = Quaternion(-0.528109, -0.11616986, -0.028629566, 0.8407055)
|
||||
bones/42/rotation = Quaternion(-0.50738746, -0.06930056, -0.02801469, 0.85847)
|
||||
bones/42/scale = Vector3(0.7216388, 0.721639, 0.7216389)
|
||||
bones/45/rotation = Quaternion(0.18268785, -0.12150767, 0.9700416, 0.1043089)
|
||||
bones/47/rotation = Quaternion(-0.3535255, 0.012917453, 0.24260725, 0.9033243)
|
||||
bones/48/rotation = Quaternion(0.12323327, 0.07533659, 0.60708857, 0.7813972)
|
||||
bones/49/rotation = Quaternion(-0.274697, -0.030897498, -0.114820465, 0.95415056)
|
||||
bones/50/rotation = Quaternion(-0.3402536, 0.37057012, 0.46749592, 0.7268788)
|
||||
bones/51/rotation = Quaternion(-0.55072, 0.08612367, -0.0040090624, 0.83022535)
|
||||
bones/39/rotation = Quaternion(-0.08896956, -0.010968996, -0.0020401068, 0.9959719)
|
||||
bones/40/rotation = Quaternion(-0.35783374, -0.01290746, -0.008404093, 0.93365836)
|
||||
bones/41/rotation = Quaternion(-0.50213337, -0.11699159, -0.025061069, 0.8564736)
|
||||
bones/42/rotation = Quaternion(-0.47061267, -0.07042377, -0.025057614, 0.87916803)
|
||||
bones/42/scale = Vector3(0.7595928, 0.7595929, 0.75959295)
|
||||
bones/45/rotation = Quaternion(0.18396817, -0.12424846, 0.96846837, 0.113080114)
|
||||
bones/47/rotation = Quaternion(-0.41522112, 0.019539537, 0.19534181, 0.8882855)
|
||||
bones/48/rotation = Quaternion(0.093614064, 0.06956135, 0.6074395, 0.78575754)
|
||||
bones/49/rotation = Quaternion(-0.32167563, -0.017360602, -0.14304803, 0.93582094)
|
||||
bones/50/rotation = Quaternion(-0.33940473, 0.36776918, 0.44343778, 0.74358135)
|
||||
bones/51/rotation = Quaternion(-0.6044487, 0.07636927, 0.053387944, 0.7911759)
|
||||
bones/52/position = Vector3(-1.4302004e-09, 0.25003752, 1.9791896e-07)
|
||||
bones/52/rotation = Quaternion(-0.13765386, -0.038729448, 0.28803295, 0.94688356)
|
||||
bones/53/rotation = Quaternion(-0.1274389, -0.004824539, 0.24954909, 0.95992774)
|
||||
bones/52/rotation = Quaternion(-0.091176234, -0.037487358, 0.4018724, 0.9103736)
|
||||
bones/53/rotation = Quaternion(-0.10057546, 0.013901898, 0.36631107, 0.9249365)
|
||||
bones/53/scale = Vector3(1.0034515, 1.0034515, 1.0034516)
|
||||
bones/54/position = Vector3(-0.019348575, 0.12020361, 0.04075524)
|
||||
bones/55/rotation = Quaternion(0.0015297985, -0.065335885, 0.9978194, 0.009235649)
|
||||
bones/56/rotation = Quaternion(0.019904355, -0.017484719, 0.9985134, 0.047635578)
|
||||
bones/56/rotation = Quaternion(0.018764675, -0.017537005, 0.99764544, 0.063592486)
|
||||
bones/56/scale = Vector3(0.9899536, 0.9899537, 0.9899535)
|
||||
bones/58/rotation = Quaternion(-0.09557552, 0.02748879, 0.017108735, 0.9948955)
|
||||
bones/58/rotation = Quaternion(-0.13219142, 0.02840231, 0.020706926, 0.9906008)
|
||||
bones/58/scale = Vector3(1.0000032, 1.0000007, 0.9999897)
|
||||
bones/59/rotation = Quaternion(-0.19450384, 0.022933058, 0.0065517845, 0.98061174)
|
||||
bones/59/rotation = Quaternion(-0.21710877, 0.024003502, 0.008340116, 0.9758166)
|
||||
bones/59/scale = Vector3(1.0000062, 0.99999875, 0.9999899)
|
||||
bones/60/rotation = Quaternion(-0.29665518, 0.11391603, -0.049912177, 0.94685143)
|
||||
bones/60/rotation = Quaternion(-0.30197915, 0.1142515, -0.04919708, 0.94516397)
|
||||
bones/60/scale = Vector3(1.0000336, 0.9999861, 0.9999709)
|
||||
bones/61/rotation = Quaternion(-0.31799996, 0.073607884, 0.0130089, 0.9451395)
|
||||
bones/61/scale = Vector3(0.9219612, 0.92196125, 0.92196125)
|
||||
bones/63/rotation = Quaternion(-0.11152567, -0.109183915, 0.68197995, 0.71452385)
|
||||
bones/64/rotation = Quaternion(7.67878e-05, 0.007894828, -0.5078632, 0.8614015)
|
||||
bones/61/rotation = Quaternion(-0.36849403, 0.07279947, 0.0169585, 0.92662007)
|
||||
bones/61/scale = Vector3(0.9024252, 0.9024252, 0.90242535)
|
||||
bones/63/rotation = Quaternion(-0.14057827, -0.13962975, 0.67658895, 0.7092029)
|
||||
bones/64/rotation = Quaternion(-0.0008730317, 0.009476024, -0.5697095, 0.82179105)
|
||||
bones/64/scale = Vector3(0.99996406, 1.0000201, 1.0000011)
|
||||
bones/65/rotation = Quaternion(0.003934607, -0.0059709265, -0.14832197, 0.9889133)
|
||||
bones/65/rotation = Quaternion(0.007987887, -0.0050761225, -0.42519358, 0.905053)
|
||||
bones/65/scale = Vector3(0.9999612, 1.0000443, 0.9999987)
|
||||
bones/66/rotation = Quaternion(-0.00035578068, 0.0040411754, -0.56801844, 0.8230059)
|
||||
bones/66/scale = Vector3(0.99691063, 0.9969107, 0.99691063)
|
||||
bones/69/rotation = Quaternion(-0.10783173, 0.02835082, 0.026758341, 0.9934045)
|
||||
bones/66/rotation = Quaternion(-0.0011968529, 0.0038762295, -0.7282474, 0.6853024)
|
||||
bones/66/scale = Vector3(0.89088875, 0.89088875, 0.89088875)
|
||||
bones/69/rotation = Quaternion(-0.11573826, 0.02977971, 0.029024689, 0.9924089)
|
||||
bones/69/scale = Vector3(1.0000011, 1.000003, 0.9999902)
|
||||
bones/70/rotation = Quaternion(-0.24864742, 0.024019485, 0.009138298, 0.9682531)
|
||||
bones/70/rotation = Quaternion(-0.29088214, 0.02523708, 0.010372228, 0.9563698)
|
||||
bones/70/scale = Vector3(1.0000064, 0.9999984, 0.99998826)
|
||||
bones/71/rotation = Quaternion(-0.3498448, 0.11234594, -0.05669889, 0.92831695)
|
||||
bones/71/rotation = Quaternion(-0.3923937, 0.11099149, -0.062451553, 0.91093796)
|
||||
bones/71/scale = Vector3(1.0000288, 0.9999696, 0.9999856)
|
||||
bones/72/rotation = Quaternion(-0.38113746, 0.070154205, 0.023761185, 0.9215466)
|
||||
bones/72/scale = Vector3(0.88499427, 0.88499427, 0.8849943)
|
||||
bones/75/rotation = Quaternion(-0.44955254, 0.071000256, 0.02337428, 0.89012086)
|
||||
bones/75/scale = Vector3(0.7869878, 0.78698796, 0.7869879)
|
||||
bones/77/rotation = Quaternion(-0.08044924, 0.031930048, 0.021748522, 0.99600977)
|
||||
bones/72/rotation = Quaternion(-0.42618927, 0.06889496, 0.02719724, 0.9015967)
|
||||
bones/72/scale = Vector3(0.83766246, 0.8376625, 0.8376625)
|
||||
bones/75/rotation = Quaternion(-0.48680955, 0.06994776, 0.026357254, 0.8703041)
|
||||
bones/75/scale = Vector3(0.74701124, 0.7470114, 0.74701136)
|
||||
bones/77/rotation = Quaternion(-0.08930568, 0.0330875, 0.023779208, 0.99517053)
|
||||
bones/77/scale = Vector3(1.0000033, 1.000001, 0.999991)
|
||||
bones/78/rotation = Quaternion(-0.34354696, 0.025710205, 0.0117785605, 0.9387097)
|
||||
bones/78/rotation = Quaternion(-0.3771892, 0.026854906, 0.012287962, 0.9256652)
|
||||
bones/78/scale = Vector3(1.0000068, 0.9999958, 0.9999893)
|
||||
bones/79/rotation = Quaternion(-0.46400115, 0.107296966, -0.072941825, 0.87628186)
|
||||
bones/79/rotation = Quaternion(-0.49504524, 0.10594434, -0.07731571, 0.8589111)
|
||||
bones/79/scale = Vector3(1.0000231, 0.9999459, 1.0000087)
|
||||
bones/81/rotation = Quaternion(-0.1560703, -0.09879844, 0.98091835, 0.060664196)
|
||||
bones/81/rotation = Quaternion(-0.15335086, -0.0949378, 0.98063666, 0.07630291)
|
||||
bones/81/scale = Vector3(1.0000315, 0.99999756, 0.99996173)
|
||||
bones/82/scale = Vector3(0.8060068, 0.72331333, 0.8060064)
|
||||
bones/84/rotation = Quaternion(0.49998438, -0.49998462, 0.50001407, 0.5000171)
|
||||
@@ -460,79 +460,78 @@ bones/89/rotation = Quaternion(-1.7506047e-05, 0.0075047514, 0.99997187, -3.4665
|
||||
bones/90/position = Vector3(-5.171567e-06, 0.109669246, -0.026608149)
|
||||
bones/91/position = Vector3(0.00028568288, 1.3881216e-06, -0.11966742)
|
||||
bones/92/position = Vector3(-4.487067e-06, 0.00059545063, 0.026699075)
|
||||
bones/95/rotation = Quaternion(-0.2445412, -0.008091147, -0.0031324434, 0.96960014)
|
||||
bones/96/rotation = Quaternion(0.13539134, -0.111401506, -0.45223352, 0.87449634)
|
||||
bones/97/rotation = Quaternion(-0.16585478, 0.06289295, 0.27902722, 0.94375867)
|
||||
bones/98/rotation = Quaternion(0.9996835, -0.020963965, -0.01376136, -0.0020327854)
|
||||
bones/99/rotation = Quaternion(0.6971754, 0.16330299, 0.5107794, -0.47579718)
|
||||
bones/100/rotation = Quaternion(-0.09672974, -0.2707916, 0.8893904, 0.3553872)
|
||||
bones/101/rotation = Quaternion(-0.16997941, -0.36925218, 0.91084087, 0.07161498)
|
||||
bones/102/rotation = Quaternion(0.27458468, 0.76884073, -0.56566775, 0.11622049)
|
||||
bones/103/rotation = Quaternion(0.050467182, -0.02689886, 0.0101633305, 0.9983117)
|
||||
bones/104/rotation = Quaternion(-0.63060206, 0.25909388, 0.5924461, 0.4292076)
|
||||
bones/105/rotation = Quaternion(0.09857185, -0.33795524, 0.8416281, -0.40955094)
|
||||
bones/106/rotation = Quaternion(0.17382921, -0.3878289, 0.90434283, -0.039195843)
|
||||
bones/107/rotation = Quaternion(-0.26671234, 0.77850264, -0.5583155, -0.10527194)
|
||||
bones/108/rotation = Quaternion(0.032056976, 0.030584559, 0.0133192185, 0.9989292)
|
||||
bones/95/rotation = Quaternion(-0.3251402, -0.01527947, 0.04097657, 0.94465405)
|
||||
bones/96/rotation = Quaternion(0.1005211, -0.10709623, -0.43766668, 0.8870591)
|
||||
bones/97/rotation = Quaternion(-0.18717939, 0.055158578, 0.3601579, 0.9122543)
|
||||
bones/98/rotation = Quaternion(0.99858093, -0.03544568, 0.00032211392, -0.039745476)
|
||||
bones/99/rotation = Quaternion(0.70849836, 0.14360382, 0.48341495, -0.49367815)
|
||||
bones/100/rotation = Quaternion(-0.07304252, -0.1529403, 0.89772147, 0.40665764)
|
||||
bones/101/rotation = Quaternion(-0.14937876, -0.15967666, 0.95516163, 0.19963908)
|
||||
bones/102/rotation = Quaternion(0.24430214, 0.8274061, -0.49542272, 0.101351805)
|
||||
bones/103/rotation = Quaternion(0.053667642, -0.03664518, 0.040495515, 0.99706423)
|
||||
bones/104/rotation = Quaternion(-0.6321686, 0.25477147, 0.60052764, 0.41811606)
|
||||
bones/105/rotation = Quaternion(0.07162597, -0.16432492, 0.8853666, -0.4289441)
|
||||
bones/106/rotation = Quaternion(0.15118112, -0.19262818, 0.95249426, -0.18108976)
|
||||
bones/107/rotation = Quaternion(-0.23120722, 0.7898773, -0.56800413, -0.0028981324)
|
||||
bones/108/rotation = Quaternion(0.023904754, 0.05177306, -0.004932024, 0.9983606)
|
||||
bones/109/rotation = Quaternion(0.99767774, 1.556075e-10, -9.531183e-10, -0.068111084)
|
||||
bones/110/rotation = Quaternion(0.99683416, -1.6933579e-09, -1.059075e-09, -0.07951008)
|
||||
bones/111/rotation = Quaternion(0.99683416, -7.121785e-10, -1.371535e-10, -0.07951002)
|
||||
bones/112/rotation = Quaternion(0.9966826, -0.044638164, -0.0005414448, -0.0680515)
|
||||
bones/113/rotation = Quaternion(0.9987199, 0.02195364, 0.004492195, -0.045348335)
|
||||
bones/114/position = Vector3(0.089599155, 0.109603494, 0.12849061)
|
||||
bones/114/rotation = Quaternion(-0.039908078, 0.7459613, 0.66389, 0.03462947)
|
||||
bones/115/position = Vector3(-0.11258449, 0.1060466, 0.11613239)
|
||||
bones/115/rotation = Quaternion(-0.033876516, 0.74464214, 0.6651905, 0.04338425)
|
||||
bones/116/rotation = Quaternion(0.9490221, 0.049272522, -0.0024085855, 0.31132534)
|
||||
bones/112/rotation = Quaternion(0.99779993, 0.012861086, 1.0161915e-05, -0.0650386)
|
||||
bones/113/rotation = Quaternion(0.9988099, -0.006719865, -0.001447611, -0.048286617)
|
||||
bones/114/position = Vector3(0.10667643, 0.10764104, 0.122555554)
|
||||
bones/114/rotation = Quaternion(0.011519142, 0.7421831, 0.670045, -0.008446671)
|
||||
bones/115/position = Vector3(-0.09716021, 0.10826578, 0.12593862)
|
||||
bones/115/rotation = Quaternion(0.012489614, 0.7422756, 0.6699413, -0.007050324)
|
||||
bones/116/rotation = Quaternion(0.91591984, 0.041743204, -0.038060818, 0.39736617)
|
||||
bones/116/scale = Vector3(1.0000001, 1.0000073, 1.0000031)
|
||||
bones/117/rotation = Quaternion(0.29462653, 1.9595986e-07, -8.5539654e-08, 0.95561254)
|
||||
bones/117/rotation = Quaternion(0.2129173, -1.7204357e-08, 2.2105743e-08, 0.9770703)
|
||||
bones/117/scale = Vector3(0.9999999, 1.0000029, 0.9999938)
|
||||
bones/118/rotation = Quaternion(0.16041467, -7.4143813e-10, -1.8532849e-09, 0.9870497)
|
||||
bones/118/scale = Vector3(1.0025107, 1.0025107, 1.0025107)
|
||||
bones/118/rotation = Quaternion(0.11293654, 6.085276e-10, -2.1824627e-09, 0.9936023)
|
||||
bones/118/scale = Vector3(1.0250566, 1.0250566, 1.0250558)
|
||||
bones/119/position = Vector3(1.42586645e-08, 0.44729978, -2.2977348e-08)
|
||||
bones/119/rotation = Quaternion(-0.5205635, -0.04861698, -0.009150065, 0.8523887)
|
||||
bones/119/rotation = Quaternion(-0.56321955, -0.085332386, -0.00023525587, 0.82188934)
|
||||
bones/119/scale = Vector3(1.0000006, 1.0000005, 1.0000006)
|
||||
bones/120/rotation = Quaternion(1.2078932e-08, 0.9239634, -0.38248104, -4.1733063e-08)
|
||||
bones/120/rotation = Quaternion(1.6713186e-08, 0.9593813, -0.28211272, -4.0647432e-08)
|
||||
bones/121/rotation = Quaternion(-0.38443583, 7.889533e-10, -4.0391046e-09, 0.92315173)
|
||||
bones/122/position = Vector3(-1.08986505e-07, 0.089753166, -0.124332145)
|
||||
bones/122/rotation = Quaternion(0.97857517, -4.119068e-07, 6.66014e-09, 0.20589004)
|
||||
bones/122/position = Vector3(-1.1141086e-07, 0.0866726, -0.1240637)
|
||||
bones/122/rotation = Quaternion(0.98830485, 2.4008582e-08, -2.1740785e-09, 0.15249106)
|
||||
bones/122/scale = Vector3(0.9999999, 1.0000045, 1.0000539)
|
||||
bones/123/position = Vector3(-1.0885971e-09, 0.06843925, -0.12920402)
|
||||
bones/124/rotation = Quaternion(0.8985224, -0.098785, 0.07873928, 0.42035618)
|
||||
bones/123/position = Vector3(-1.2398929e-09, 0.055202506, -0.12983651)
|
||||
bones/124/rotation = Quaternion(0.9582158, -0.012951803, 0.030829843, 0.2840851)
|
||||
bones/124/scale = Vector3(1.0000002, 1.0000051, 1.0000046)
|
||||
bones/125/rotation = Quaternion(0.26762056, 1.1755564e-07, -1.4920035e-07, 0.9635244)
|
||||
bones/125/rotation = Quaternion(0.32768983, -3.252524e-08, 9.529529e-08, 0.94478536)
|
||||
bones/125/scale = Vector3(1.0000004, 0.99999994, 0.99999815)
|
||||
bones/126/rotation = Quaternion(0.1729003, 2.709651e-09, -7.849513e-10, 0.98493934)
|
||||
bones/126/scale = Vector3(1.0361892, 1.0361903, 1.0361874)
|
||||
bones/126/rotation = Quaternion(0.19387913, -2.4527507e-09, -2.0338708e-09, 0.9810255)
|
||||
bones/126/scale = Vector3(1.0136434, 1.0136434, 1.0136424)
|
||||
bones/127/position = Vector3(0.017543899, 0.4470914, -0.0017586505)
|
||||
bones/127/rotation = Quaternion(-0.62358737, 0.056855906, -0.058975216, 0.77744985)
|
||||
bones/127/rotation = Quaternion(-0.62508345, 0.06880486, -0.034627527, 0.77674806)
|
||||
bones/127/scale = Vector3(0.9999995, 1.0000002, 1.0000019)
|
||||
bones/128/rotation = Quaternion(1.5757598e-08, 0.9431326, -0.33241698, -4.0942414e-08)
|
||||
bones/128/rotation = Quaternion(1.4744123e-08, 0.9348427, -0.35506225, -4.1168715e-08)
|
||||
bones/129/rotation = Quaternion(-0.38443583, -5.8626265e-10, 2.3708009e-09, 0.92315173)
|
||||
bones/130/position = Vector3(9.777668e-08, 0.087202854, -0.12410998)
|
||||
bones/130/rotation = Quaternion(0.9813956, -5.0358e-07, 2.0156255e-08, 0.1919968)
|
||||
bones/130/position = Vector3(9.795805e-08, 0.0871207, -0.12410282)
|
||||
bones/130/rotation = Quaternion(0.9721331, -2.4233276e-07, 1.8562186e-08, 0.23443)
|
||||
bones/130/scale = Vector3(1.0000001, 1.0000031, 1.0000556)
|
||||
bones/131/position = Vector3(-3.291853e-09, 0.057136707, -0.12974413)
|
||||
bones/132/position = Vector3(0.18572016, 1.8411512, 1.0656314)
|
||||
bones/133/position = Vector3(-0.09007099, 1.8411512, 1.0656314)
|
||||
bones/134/position = Vector3(0.3152761, 1.5845517, -0.2712663)
|
||||
bones/135/position = Vector3(-0.11172535, 1.4797182, -0.14338115)
|
||||
bones/131/position = Vector3(-9.453848e-10, 0.057104174, -0.1297457)
|
||||
bones/132/position = Vector3(0.18157458, 1.8411512, 1.0656314)
|
||||
bones/133/position = Vector3(-0.09421658, 1.8411512, 1.0656314)
|
||||
bones/134/position = Vector3(0.32077587, 1.3926959, -0.05326869)
|
||||
bones/135/position = Vector3(-0.09503438, 1.5833519, -0.37742868)
|
||||
bones/135/rotation = Quaternion(0.998099, -2.2223412e-10, 0.061630115, 3.5990741e-09)
|
||||
bones/136/position = Vector3(-0.03036772, 2.5206814, 7.7702985)
|
||||
bones/137/position = Vector3(0.5086129, 2.3673053, -0.13149378)
|
||||
bones/136/position = Vector3(-0.039492957, 3.0015063, 7.770298)
|
||||
bones/137/position = Vector3(0.53396547, 2.337483, -0.3645535)
|
||||
bones/137/rotation = Quaternion(-0.70707756, 0.0064321673, -0.0064321654, 0.7070775)
|
||||
bones/138/position = Vector3(0.69004935, 2.5061495, -0.39663178)
|
||||
bones/139/position = Vector3(-0.3504521, 2.404392, -0.058537085)
|
||||
bones/138/position = Vector3(0.51160735, 2.6495035, -0.39727944)
|
||||
bones/139/position = Vector3(-0.27565652, 2.444648, 0.1582382)
|
||||
bones/139/rotation = Quaternion(-0.70707756, 0.0064321673, -0.0064321654, 0.7070775)
|
||||
bones/140/position = Vector3(-0.35025254, 2.7532718, -0.38271895)
|
||||
bones/141/position = Vector3(0.1378957, 1.3834102, -0.62697816)
|
||||
bones/142/position = Vector3(-0.1378957, 1.3860018, -0.6269781)
|
||||
bones/143/position = Vector3(-0.007065243, 3.2163112, -1.2437935)
|
||||
bones/143/rotation = Quaternion(0.9969156, 0, 0.07848113, 0)
|
||||
bones/143/scale = Vector3(1, 0.98573476, 1)
|
||||
bones/140/position = Vector3(-0.46933034, 2.6052446, -0.3798879)
|
||||
bones/142/position = Vector3(-0.1378957, 1.3859, -0.6269781)
|
||||
bones/143/position = Vector3(0.013954439, 3.2327185, -1.2437935)
|
||||
bones/143/rotation = Quaternion(0.9997545, 0, -0.022156853, 0)
|
||||
bones/143/scale = Vector3(1, 1.025109, 1)
|
||||
|
||||
[node name="GunBone" type="BoneAttachment3D" parent="PlayerModel/Robot_Skeleton/Skeleton3D" index="5"]
|
||||
transform = Transform3D(0.088873334, 0.36089236, -0.93208843, 0.4157426, 0.8376457, 0.3639617, 0.90908164, -0.41835597, -0.075325064, -0.39473683, 1.0766551, -0.09200796)
|
||||
transform = Transform3D(0.34979135, 0.14367425, -0.92949647, 0.7594839, 0.5419456, 0.3695154, 0.5549772, -0.83220714, 0.080163114, -0.31333226, 1.1718442, 0.14094272)
|
||||
bone_name = "hand.R"
|
||||
bone_idx = 55
|
||||
|
||||
|
||||
@@ -1,40 +1,41 @@
|
||||
class_name PlayerInputSynchronizer
|
||||
extends MultiplayerSynchronizer
|
||||
|
||||
const CAMERA_CONTROLLER_ROTATION_SPEED := 3.0
|
||||
const CAMERA_MOUSE_ROTATION_SPEED := 0.001
|
||||
const CAMERA_CONTROLLER_ROTATION_SPEED: float = 3.0
|
||||
const CAMERA_MOUSE_ROTATION_SPEED: float = 0.001
|
||||
# A minimum angle lower than or equal to -90 breaks movement if the player is looking upward.
|
||||
const CAMERA_X_ROT_MIN := deg_to_rad(-89.9)
|
||||
const CAMERA_X_ROT_MAX := deg_to_rad(70)
|
||||
const CAMERA_X_ROT_MIN: float = deg_to_rad(-89.9)
|
||||
const CAMERA_X_ROT_MAX: float = deg_to_rad(70.0)
|
||||
|
||||
# Release aiming if the mouse/gamepad button was held for longer than 0.4 seconds.
|
||||
# This works well for trackpads and is more accessible by not making long presses a requirement.
|
||||
# If the aiming button was held for less than 0.4 seconds, keep aiming until the aiming button is pressed again.
|
||||
const AIM_HOLD_THRESHOLD = 0.4
|
||||
const AIM_HOLD_THRESHOLD: float = 0.4
|
||||
|
||||
# If `true`, the aim button was toggled checked by a short press (instead of being held down).
|
||||
var toggled_aim := false
|
||||
var toggled_aim: bool = false
|
||||
|
||||
# The duration the aiming button was held for (in seconds).
|
||||
var aiming_timer := 0.0
|
||||
var aiming_timer: float = 0.0
|
||||
|
||||
# Synchronized controls
|
||||
@export var aiming := false
|
||||
@export var aiming: bool = false
|
||||
@export var shoot_target := Vector3()
|
||||
@export var motion := Vector2()
|
||||
@export var shooting := false
|
||||
@export var shooting: bool = false
|
||||
# This is handled via RPC for now
|
||||
@export var jumping := false
|
||||
@export var jumping: bool = false
|
||||
|
||||
# Camera and effects
|
||||
@export var camera_animation : AnimationPlayer
|
||||
@export var crosshair : TextureRect
|
||||
@export var camera_base : Node3D
|
||||
@export var camera_rot : Node3D
|
||||
@export var camera_camera : Camera3D
|
||||
@export var color_rect : ColorRect
|
||||
@export var camera_animation: AnimationPlayer
|
||||
@export var crosshair: TextureRect
|
||||
@export var camera_base: Node3D
|
||||
@export var camera_rot: Node3D
|
||||
@export var camera_camera: Camera3D
|
||||
@export var color_rect: ColorRect
|
||||
|
||||
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
if get_multiplayer_authority() == multiplayer.get_unique_id():
|
||||
camera_camera.make_current()
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
@@ -43,21 +44,22 @@ func _ready():
|
||||
set_process_input(false)
|
||||
color_rect.hide()
|
||||
|
||||
func _process(delta):
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
motion = Vector2(
|
||||
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
|
||||
Input.get_action_strength("move_back") - Input.get_action_strength("move_forward"))
|
||||
var camera_move = Vector2(
|
||||
Input.get_action_strength("view_right") - Input.get_action_strength("view_left"),
|
||||
Input.get_action_strength("view_up") - Input.get_action_strength("view_down"))
|
||||
var camera_speed_this_frame = delta * CAMERA_CONTROLLER_ROTATION_SPEED
|
||||
Input.get_action_strength(&"move_right") - Input.get_action_strength(&"move_left"),
|
||||
Input.get_action_strength(&"move_back") - Input.get_action_strength(&"move_forward"))
|
||||
var camera_move := Vector2(
|
||||
Input.get_action_strength(&"view_right") - Input.get_action_strength(&"view_left"),
|
||||
Input.get_action_strength(&"view_up") - Input.get_action_strength(&"view_down"))
|
||||
var camera_speed_this_frame: float = delta * CAMERA_CONTROLLER_ROTATION_SPEED
|
||||
if aiming:
|
||||
camera_speed_this_frame *= 0.5
|
||||
rotate_camera(camera_move * camera_speed_this_frame)
|
||||
var current_aim = false
|
||||
var current_aim: bool = false
|
||||
|
||||
# Keep aiming if the mouse wasn't held for long enough.
|
||||
if Input.is_action_just_released("aim") and aiming_timer <= AIM_HOLD_THRESHOLD:
|
||||
if Input.is_action_just_released(&"aim") and aiming_timer <= AIM_HOLD_THRESHOLD:
|
||||
current_aim = true
|
||||
toggled_aim = true
|
||||
else:
|
||||
@@ -88,40 +90,40 @@ func _process(delta):
|
||||
|
||||
var col = get_parent().get_world_3d().direct_space_state.intersect_ray(PhysicsRayQueryParameters3D.create(ray_from, ray_from + ray_dir * 1000, 0b11, Array([self], TYPE_RID, "", null)))
|
||||
if col.is_empty():
|
||||
shoot_target = ray_from + ray_dir * 1000
|
||||
shoot_target = ray_from + ray_dir * 1000.0
|
||||
else:
|
||||
shoot_target = col.position
|
||||
|
||||
# Fade out to black if falling out of the map. -17 is lower than
|
||||
# the lowest valid position checked the map (which is a bit under -16).
|
||||
# At 15 units below -17 (so -32), the screen turns fully black.
|
||||
var tr : Transform3D = get_parent().global_transform
|
||||
if tr.origin.y < -17:
|
||||
color_rect.modulate.a = min((-17 - tr.origin.y) / 15, 1)
|
||||
var player_transform: Transform3D = get_parent().global_transform
|
||||
if player_transform.origin.y < -17.0:
|
||||
color_rect.modulate.a = minf((-17.0 - player_transform.origin.y) / 15.0, 1.0)
|
||||
else:
|
||||
# Fade out the black ColorRect progressively after being teleported back.
|
||||
color_rect.modulate.a *= 1.0 - delta * 4
|
||||
color_rect.modulate.a *= 1.0 - delta * 4.0
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseMotion:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseMotion:
|
||||
var camera_speed_this_frame = CAMERA_MOUSE_ROTATION_SPEED
|
||||
if aiming:
|
||||
camera_speed_this_frame *= 0.75
|
||||
rotate_camera(event.screen_relative * camera_speed_this_frame)
|
||||
rotate_camera(input_event.screen_relative * camera_speed_this_frame)
|
||||
|
||||
|
||||
func rotate_camera(move):
|
||||
func rotate_camera(move: Vector2) -> void:
|
||||
camera_base.rotate_y(-move.x)
|
||||
# After relative transforms, camera needs to be renormalized.
|
||||
camera_base.orthonormalize()
|
||||
camera_rot.rotation.x = clamp(camera_rot.rotation.x + move.y, CAMERA_X_ROT_MIN, CAMERA_X_ROT_MAX)
|
||||
camera_rot.rotation.x = clampf(camera_rot.rotation.x + move.y, CAMERA_X_ROT_MIN, CAMERA_X_ROT_MAX)
|
||||
|
||||
|
||||
func get_aim_rotation():
|
||||
var camera_x_rot = clamp(camera_rot.rotation.x, CAMERA_X_ROT_MIN, CAMERA_X_ROT_MAX)
|
||||
func get_aim_rotation() -> float:
|
||||
var camera_x_rot: float = clampf(camera_rot.rotation.x, CAMERA_X_ROT_MIN, CAMERA_X_ROT_MAX)
|
||||
# Change aim according to camera rotation.
|
||||
if camera_x_rot >= 0: # Aim up.
|
||||
if camera_x_rot >= 0.0: # Aim up.
|
||||
return -camera_x_rot / CAMERA_X_ROT_MAX
|
||||
else: # Aim down.
|
||||
return camera_x_rot / CAMERA_X_ROT_MIN
|
||||
@@ -136,5 +138,5 @@ func get_camera_rotation_basis() -> Basis:
|
||||
|
||||
|
||||
@rpc("call_local")
|
||||
func jump():
|
||||
func jump() -> void:
|
||||
jumping = true
|
||||
|
||||
Reference in New Issue
Block a user