mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-20 03:54:47 +00:00
Merge branch 'feature/IFF-updates' into 'develop'
✨ IFF Updates See merge request open-fpsz/open-fpsz!32
This commit is contained in:
commit
7f593d2134
|
|
@ -1,5 +0,0 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://b8xj25dhhbagw"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bftyiy6r0xaa3" path="res://entities/flag/assets/flag.glb" id="1_pd02q"]
|
||||
|
||||
[node name="flag2" instance=ExtResource("1_pd02q")]
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://c88l3h0ph00c7"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://c88l3h0ph00c7"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/flag/flag.gd" id="1_y7d3d"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3l7fvbdg6m5g" path="res://entities/flag/assets/flag.glb" id="2_i78em"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqrx87qbea1pr" path="res://entities/flag/assets/flag.glb" id="2_i78em"]
|
||||
[ext_resource type="PackedScene" uid="uid://bcgkc5fhhyauv" path="res://entities/flag/waypoint.tscn" id="3_tu6jg"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_4ymrw"]
|
||||
bounce = 0.5
|
||||
|
|
@ -42,3 +43,9 @@ shape = SubResource("BoxShape3D_fkf1k")
|
|||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_lpijf")
|
||||
|
||||
[node name="WaypointAttachment" type="Marker3D" parent="."]
|
||||
|
||||
[node name="Waypoint" parent="WaypointAttachment" node_paths=PackedStringArray("attach_point", "flag") instance=ExtResource("3_tu6jg")]
|
||||
attach_point = NodePath("..")
|
||||
flag = NodePath("../..")
|
||||
|
|
|
|||
49
entities/flag/waypoint.gd
Normal file
49
entities/flag/waypoint.gd
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# This file is part of open-fpsz.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
extends Control
|
||||
|
||||
@export var attach_point : Node3D
|
||||
@export var flag : Flag
|
||||
|
||||
@onready var _iff_container : Control = $IFFContainer
|
||||
|
||||
func _ready() -> void:
|
||||
attach_point.transform = attach_point.transform.translated(
|
||||
Vector3(0, flag.get_node("CollisionShape3D").shape.size.y, 0))
|
||||
|
||||
func _process(_delta : float) -> void:
|
||||
var camera : Camera3D = get_viewport().get_camera_3d()
|
||||
var viewport_rect : Rect2 = get_viewport_rect()
|
||||
# if the player is NOT infront of the camera or camera does NOT have LOS to player
|
||||
if camera.is_position_behind(attach_point.global_position):
|
||||
_iff_container.hide() # hide the IFF and exit function
|
||||
return
|
||||
else:
|
||||
_iff_container.show() # display the IFF
|
||||
|
||||
# get the screen location of the players head
|
||||
var new_iff_position : Vector2 = camera.unproject_position(attach_point.global_position)
|
||||
|
||||
# check if the unprojected point lies inside the viewport
|
||||
if !Rect2(Vector2(0, 0), viewport_rect.size).has_point(new_iff_position):
|
||||
_iff_container.hide() # hide the IFF and exit function
|
||||
return
|
||||
|
||||
# move the IFF up so the bottom of it is at the players head
|
||||
new_iff_position.y -= _iff_container.size.y
|
||||
# move the IFF left so it's centered horizontally above players head
|
||||
new_iff_position.x -= _iff_container.size.x / 2
|
||||
# set the position of the IFF
|
||||
position = new_iff_position
|
||||
27
entities/flag/waypoint.tscn
Normal file
27
entities/flag/waypoint.tscn
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bcgkc5fhhyauv"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/flag/waypoint.gd" id="1_gmnl6"]
|
||||
|
||||
[node name="IFF" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_gmnl6")
|
||||
|
||||
[node name="IFFContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_right = 11.0
|
||||
offset_bottom = 20.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Chevron" type="Label" parent="IFFContainer"]
|
||||
layout_direction = 2
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 1
|
||||
theme_override_colors/font_color = Color(0, 1, 1, 0.784314)
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
theme_override_constants/outline_size = 3
|
||||
theme_override_constants/line_spacing = -20
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "▼"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 2
|
||||
|
|
@ -16,6 +16,8 @@ class_name Player extends RigidBody3D
|
|||
|
||||
enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
||||
|
||||
@export var iff : Control
|
||||
|
||||
@export_category("Parameters")
|
||||
@export var ground_speed : float = 48 / 3.6 # m/s
|
||||
@export var aerial_control_force : int = 400
|
||||
|
|
@ -42,11 +44,11 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
|||
@onready var input : PlayerInput = $PlayerInput
|
||||
@onready var camera : Camera3D = $SpringArm3D/Camera3D
|
||||
@onready var hud : CanvasLayer = $HUD
|
||||
@onready var iff : Node2D = $ThirdPerson/IFF
|
||||
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
|
||||
@onready var weapon : Node3D = $SpringArm3D/Inventory/SpaceGun
|
||||
@onready var animation_player : AnimationPlayer = $AnimationPlayer
|
||||
@onready var health_component : Area3D = $HealthComponent
|
||||
@onready var collision_shape : CollisionShape3D = $CollisionShape3D
|
||||
@onready var flag_carry_component : FlagCarryComponent = $FlagCarryComponent
|
||||
@onready var spring_arm_height : float = $SpringArm3D.position.y
|
||||
@onready var _original_weapon_transform : Transform3D = weapon.transform
|
||||
|
|
@ -62,22 +64,30 @@ var _jumping : bool = false
|
|||
|
||||
func _ready() -> void:
|
||||
energy_changed.connect(hud._on_energy_changed)
|
||||
if _is_pawn():
|
||||
health_component.health_changed.connect(hud._on_health_changed)
|
||||
camera.current = true
|
||||
camera.fov = _game_settings.fov
|
||||
remove_child($ThirdPerson)
|
||||
else:
|
||||
health_component.health_changed.connect(iff._on_health_changed)
|
||||
remove_child(hud)
|
||||
weapon.hide()
|
||||
health_component.health_changed.connect(hud._on_health_changed)
|
||||
health_component.health_changed.connect(iff._on_health_changed)
|
||||
health_component.health_changed.emit(health_component.health)
|
||||
health_component.health_zeroed.connect(die)
|
||||
input.MOUSE_SENSITIVITY = _game_settings.mouse_sensitivity
|
||||
input.inverted_y_axis = _game_settings.inverted_y_axis
|
||||
|
||||
input.fired_primary.connect(_fire_primary)
|
||||
input.jumped.connect(_jump)
|
||||
input.throwed_flag.connect(_throw_flag)
|
||||
|
||||
input.MOUSE_SENSITIVITY = _game_settings.mouse_sensitivity
|
||||
input.inverted_y_axis = _game_settings.inverted_y_axis
|
||||
|
||||
if _is_pawn():
|
||||
camera.current = true
|
||||
camera.fov = _game_settings.fov
|
||||
# set the spring arm translation to be about head height level
|
||||
$SpringArm3D.transform = Transform3D().translated(Vector3(0, collision_shape.shape.height / 2, 0) * 0.9)
|
||||
flag_carry_attachment.hide()
|
||||
remove_child($ThirdPerson)
|
||||
else:
|
||||
# set the iff attachment translation to be about head height level
|
||||
$ThirdPerson/IFFAttachment.transform = Transform3D().translated(Vector3(0, collision_shape.shape.height / 2, 0) * 0.9)
|
||||
remove_child(hud)
|
||||
weapon.hide()
|
||||
|
||||
func _is_pawn() -> bool:
|
||||
return player_id == multiplayer.get_unique_id()
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
[ext_resource type="PackedScene" uid="uid://drbefw6akui2v" path="res://entities/player/assets/vanguard.tscn" id="2_beyex"]
|
||||
[ext_resource type="Shape3D" uid="uid://cb8esdlnottdn" path="res://entities/player/collision_shape.tres" id="2_vjqny"]
|
||||
[ext_resource type="PackedScene" uid="uid://bcv81ku26xo" path="res://interfaces/hud/hud.tscn" id="3_ccety"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8co0qa2omjmh" path="res://entities/weapons/space_gun/space_gun.tscn" id="4_6jh57"]
|
||||
[ext_resource type="PackedScene" uid="uid://dn1tcakam5egs" path="res://entities/weapons/space_gun/projectile.tscn" id="5_2xh36"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8co0qa2omjmh" path="res://entities/weapons/space_gun/space_gun.tscn" id="4_ehwwq"]
|
||||
[ext_resource type="PackedScene" uid="uid://bof3mg7wgxrmn" path="res://components/health_component.tscn" id="5_t6i6e"]
|
||||
[ext_resource type="PackedScene" uid="uid://dn1tcakam5egs" path="res://entities/weapons/space_gun/projectile.tscn" id="5_w56pa"]
|
||||
[ext_resource type="Script" path="res://entities/player/player_input.gd" id="6_ymcrr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dsysi2rd3bu76" path="res://interfaces/hud/iff.tscn" id="7_8hc80"]
|
||||
[ext_resource type="PackedScene" uid="uid://2t8ql8pkxv6c" path="res://components/flag_carry_component.tscn" id="7_e7s1a"]
|
||||
|
|
@ -198,7 +198,7 @@ properties/3/path = NodePath(".:skiing")
|
|||
properties/3/spawn = false
|
||||
properties/3/replication_mode = 2
|
||||
|
||||
[node name="Player" type="RigidBody3D"]
|
||||
[node name="Player" type="RigidBody3D" node_paths=PackedStringArray("iff")]
|
||||
collision_mask = 2147483649
|
||||
axis_lock_angular_x = true
|
||||
axis_lock_angular_y = true
|
||||
|
|
@ -207,6 +207,7 @@ mass = 75.0
|
|||
physics_material_override = SubResource("PhysicsMaterial_clur0")
|
||||
continuous_cd = true
|
||||
script = ExtResource("1_mk68k")
|
||||
iff = NodePath("ThirdPerson/IFFAttachment/IFF")
|
||||
jump_height = 1.5
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
|
|
@ -244,9 +245,9 @@ near = 0.1
|
|||
|
||||
[node name="Inventory" type="Node3D" parent="SpringArm3D"]
|
||||
|
||||
[node name="SpaceGun" parent="SpringArm3D/Inventory" instance=ExtResource("4_6jh57")]
|
||||
[node name="SpaceGun" parent="SpringArm3D/Inventory" instance=ExtResource("4_ehwwq")]
|
||||
transform = Transform3D(-1, 0, 2.53518e-06, 0, 1, 0, -2.53518e-06, 0, -1, 0.244668, -0.229311, -0.30332)
|
||||
PROJECTILE = ExtResource("5_2xh36")
|
||||
PROJECTILE = ExtResource("5_w56pa")
|
||||
|
||||
[node name="SpineIKTarget" type="Node3D" parent="SpringArm3D"]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
|
||||
|
|
@ -265,17 +266,17 @@ sensor = NodePath("../Sensor")
|
|||
|
||||
[node name="ThirdPerson" type="Node3D" parent="."]
|
||||
|
||||
[node name="IFFAttachment" type="Marker3D" parent="ThirdPerson"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1, 0)
|
||||
|
||||
[node name="IFF" parent="ThirdPerson/IFFAttachment" node_paths=PackedStringArray("player", "attach_point") instance=ExtResource("7_8hc80")]
|
||||
player = NodePath("../../..")
|
||||
attach_point = NodePath("..")
|
||||
|
||||
[node name="PlayerMesh" parent="ThirdPerson" node_paths=PackedStringArray("spine_ik_target_attachment") instance=ExtResource("2_beyex")]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
|
||||
spine_ik_target_attachment = NodePath("../../SpringArm3D/SpineIKTarget")
|
||||
|
||||
[node name="IFFAttachment" type="Node3D" parent="ThirdPerson"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.27457, 0)
|
||||
|
||||
[node name="IFF" parent="ThirdPerson" node_paths=PackedStringArray("attach_point", "player") instance=ExtResource("7_8hc80")]
|
||||
attach_point = NodePath("../IFFAttachment")
|
||||
player = NodePath("../..")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_hg307")
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ var start_pos : Vector3
|
|||
func _ready() -> void:
|
||||
health_component.health_zeroed.connect(spawn)
|
||||
start_pos = global_position
|
||||
$TargetMesh/AnimationPlayer.play("gunTwoHanded")
|
||||
|
||||
func spawn() -> void:
|
||||
hide()
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://dpnu1lvfncx6q"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/target_dummy/target_dummy.gd" id="1_r02ch"]
|
||||
[ext_resource type="PackedScene" uid="uid://b83leo1ca47d7" path="res://entities/target_dummy/assets/player_mesh.blend" id="2_x73k8"]
|
||||
[ext_resource type="PackedScene" uid="uid://bof3mg7wgxrmn" path="res://components/health_component.tscn" id="3_g1ap4"]
|
||||
[ext_resource type="Script" path="res://entities/target_dummy/target_dummy.gd" id="1_iup5v"]
|
||||
[ext_resource type="Shape3D" uid="uid://cb8esdlnottdn" path="res://entities/player/collision_shape.tres" id="2_i5k5j"]
|
||||
[ext_resource type="PackedScene" uid="uid://b83leo1ca47d7" path="res://entities/target_dummy/assets/player_mesh.blend" id="2_u0wyn"]
|
||||
[ext_resource type="PackedScene" uid="uid://bof3mg7wgxrmn" path="res://components/health_component.tscn" id="4_l1exy"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_rk1ox"]
|
||||
radius = 0.3
|
||||
|
||||
[node name="TargetDummy" type="RigidBody3D"]
|
||||
[node name="DummyTarget" type="RigidBody3D"]
|
||||
collision_layer = 2147483649
|
||||
collision_mask = 2147483649
|
||||
axis_lock_angular_x = true
|
||||
|
|
@ -15,48 +13,46 @@ axis_lock_angular_y = true
|
|||
axis_lock_angular_z = true
|
||||
mass = 75.0
|
||||
continuous_cd = true
|
||||
script = ExtResource("1_r02ch")
|
||||
script = ExtResource("1_iup5v")
|
||||
|
||||
[node name="PlayerMesh" parent="." instance=ExtResource("2_x73k8")]
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = ExtResource("2_i5k5j")
|
||||
|
||||
[node name="HealthComponent" parent="." instance=ExtResource("4_l1exy")]
|
||||
|
||||
[node name="TargetMesh" parent="." instance=ExtResource("2_u0wyn")]
|
||||
transform = Transform3D(0.75, 0, 0, 0, 0.75, 0, 0, 0, 0.75, 0, -0.916438, 0)
|
||||
|
||||
[node name="Skeleton3D" parent="PlayerMesh/playerrig" index="0"]
|
||||
[node name="Skeleton3D" parent="TargetMesh/playerrig" index="0"]
|
||||
bones/0/position = Vector3(0, 0.995864, -0.0552)
|
||||
bones/0/rotation = Quaternion(0.12582, -1.79059e-15, -1.33409e-23, 0.992053)
|
||||
bones/0/scale = Vector3(1, 1, 1)
|
||||
bones/1/rotation = Quaternion(-0.0644764, 1.78006e-15, -6.67523e-16, 0.997919)
|
||||
bones/2/rotation = Quaternion(-0.0774641, 0, 0, 0.996995)
|
||||
bones/1/rotation = Quaternion(-0.0644764, 5.62483e-23, -9.26994e-23, 0.997919)
|
||||
bones/4/rotation = Quaternion(0.201738, -3.62729e-15, 4.53412e-16, 0.97944)
|
||||
bones/6/rotation = Quaternion(-0.605155, -0.345862, -0.356135, 0.622363)
|
||||
bones/7/rotation = Quaternion(-0.0464025, 0.68865, -0.38959, 0.609777)
|
||||
bones/7/rotation = Quaternion(-0.244994, 0.787594, -0.344589, 0.448255)
|
||||
bones/7/scale = Vector3(1, 1, 1)
|
||||
bones/8/rotation = Quaternion(0.185291, 0.0266179, 0.00595018, 0.982305)
|
||||
bones/8/scale = Vector3(1, 1, 1)
|
||||
bones/9/rotation = Quaternion(0.126866, -0.0346058, -0.00662176, 0.991294)
|
||||
bones/9/scale = Vector3(1, 1, 1)
|
||||
bones/10/rotation = Quaternion(0.0557877, -0.312038, -0.196665, 0.927816)
|
||||
bones/11/rotation = Quaternion(-0.0630718, -0.16283, 0.0971492, 0.979832)
|
||||
bones/13/rotation = Quaternion(0.0299552, -0.545663, -0.00259936, 0.837465)
|
||||
bones/13/scale = Vector3(1, 1, 1)
|
||||
bones/14/rotation = Quaternion(-0.0636278, -0.0624373, 0.0299354, 0.995569)
|
||||
bones/15/rotation = Quaternion(0.01399, 0.0251671, 0.0278526, 0.999197)
|
||||
bones/16/rotation = Quaternion(-0.1, -0.561252, 0.0324573, 0.82094)
|
||||
bones/17/rotation = Quaternion(0.0486079, -0.0407852, 0.014286, 0.997883)
|
||||
bones/19/rotation = Quaternion(-0.12453, -0.526036, 0.129609, 0.831252)
|
||||
bones/20/rotation = Quaternion(-0.0225172, -0.0668488, 0.0231689, 0.99724)
|
||||
bones/20/scale = Vector3(1, 1, 1)
|
||||
bones/21/rotation = Quaternion(-0.00114936, 0.0252308, -0.0174874, 0.999528)
|
||||
bones/21/scale = Vector3(1, 1, 1)
|
||||
bones/22/rotation = Quaternion(-0.192536, -0.535774, 0.0761884, 0.818579)
|
||||
bones/23/rotation = Quaternion(0.0104723, -0.0704384, 0.0293146, 0.99703)
|
||||
bones/23/scale = Vector3(1, 1, 1)
|
||||
bones/24/rotation = Quaternion(0.0334518, 0.0259883, -0.0178538, 0.998943)
|
||||
bones/25/rotation = Quaternion(-0.605155, 0.345863, 0.356135, 0.622363)
|
||||
bones/25/scale = Vector3(1, 1, 1)
|
||||
bones/26/rotation = Quaternion(-0.0464025, -0.68865, 0.38959, 0.609777)
|
||||
bones/26/rotation = Quaternion(0.0407172, -0.246634, 0.858112, 0.448506)
|
||||
bones/26/scale = Vector3(1, 1, 1)
|
||||
bones/27/rotation = Quaternion(0.185291, -0.0266179, -0.00595018, 0.982305)
|
||||
bones/27/scale = Vector3(1, 1, 1)
|
||||
bones/28/rotation = Quaternion(-0.144176, 0.0367847, -0.00247504, 0.988865)
|
||||
bones/28/rotation = Quaternion(-0.217102, 0.0422089, 0.0230507, 0.974963)
|
||||
bones/28/scale = Vector3(1, 1, 1)
|
||||
bones/30/rotation = Quaternion(-0.0630717, 0.16283, -0.0971492, 0.979832)
|
||||
bones/31/rotation = Quaternion(0.0237032, 0.0123211, -0.0433656, 0.998702)
|
||||
|
|
@ -64,41 +60,33 @@ bones/31/scale = Vector3(1, 1, 1)
|
|||
bones/32/rotation = Quaternion(0.243143, 0.523041, 0.164477, 0.800161)
|
||||
bones/32/scale = Vector3(1, 1, 1)
|
||||
bones/33/rotation = Quaternion(-0.0636278, 0.0624373, -0.0299354, 0.995569)
|
||||
bones/34/rotation = Quaternion(0.0139901, -0.0251671, -0.0278526, 0.999197)
|
||||
bones/35/rotation = Quaternion(0.113348, 0.545076, 0.134205, 0.819776)
|
||||
bones/36/rotation = Quaternion(0.0486079, 0.0407853, -0.0142859, 0.997883)
|
||||
bones/36/rotation = Quaternion(-0.4266, 0.0977703, 0.332942, 0.835226)
|
||||
bones/37/rotation = Quaternion(-0.632018, -0.129105, 0.241206, 0.725056)
|
||||
bones/38/rotation = Quaternion(0.0934222, 0.536709, 0.031309, 0.837995)
|
||||
bones/39/rotation = Quaternion(-0.0225172, 0.0668488, -0.023169, 0.99724)
|
||||
bones/40/rotation = Quaternion(-0.00114935, -0.0252307, 0.0174875, 0.999528)
|
||||
bones/39/rotation = Quaternion(-0.479327, 0.030236, 0.338389, 0.809212)
|
||||
bones/40/rotation = Quaternion(-0.540176, -0.0581251, 0.395197, 0.740709)
|
||||
bones/40/scale = Vector3(1, 1, 1)
|
||||
bones/41/rotation = Quaternion(0.0241847, 0.530538, 0.0849425, 0.843048)
|
||||
bones/41/scale = Vector3(1, 1, 1)
|
||||
bones/42/rotation = Quaternion(0.0104724, 0.0704385, -0.0293146, 0.99703)
|
||||
bones/43/rotation = Quaternion(0.0334518, -0.0259883, 0.0178538, 0.998943)
|
||||
bones/44/rotation = Quaternion(0.986515, -3.3762e-16, 5.03093e-24, 0.163672)
|
||||
bones/42/rotation = Quaternion(-0.451682, -0.0170104, 0.326969, 0.829931)
|
||||
bones/43/rotation = Quaternion(-0.512965, -0.0942157, 0.391943, 0.757873)
|
||||
bones/44/rotation = Quaternion(0.986515, -3.3762e-16, 1.34771e-25, 0.163672)
|
||||
bones/44/scale = Vector3(1, 1, 0.999997)
|
||||
bones/45/rotation = Quaternion(0.143207, -4.28623e-07, 5.19845e-06, 0.989693)
|
||||
bones/45/scale = Vector3(1, 1, 1)
|
||||
bones/46/rotation = Quaternion(-0.574131, 2.92207e-06, -4.58343e-06, 0.818763)
|
||||
bones/47/rotation = Quaternion(1.99048e-05, 0.961249, -0.27568, 4.3124e-06)
|
||||
bones/47/scale = Vector3(1, 1, 1)
|
||||
bones/48/rotation = Quaternion(0.679706, 0.679706, -0.194936, 0.194936)
|
||||
bones/49/rotation = Quaternion(0.986515, -3.3762e-16, 5.03093e-24, 0.163672)
|
||||
bones/49/rotation = Quaternion(0.986515, -3.3762e-16, 1.34771e-25, 0.163672)
|
||||
bones/49/scale = Vector3(1, 1, 0.999997)
|
||||
bones/50/rotation = Quaternion(0.143207, 4.28623e-07, -5.19845e-06, 0.989693)
|
||||
bones/50/scale = Vector3(1, 1, 1)
|
||||
bones/51/rotation = Quaternion(-0.574131, -2.92207e-06, 4.58343e-06, 0.818763)
|
||||
bones/52/rotation = Quaternion(-1.99048e-05, 0.961249, -0.27568, -4.3124e-06)
|
||||
bones/52/scale = Vector3(1, 1, 1)
|
||||
bones/53/rotation = Quaternion(0.679706, -0.679706, 0.194936, 0.194936)
|
||||
|
||||
[node name="AnimationPlayer" parent="PlayerMesh" index="4"]
|
||||
[node name="AnimationPlayer" parent="TargetMesh" index="4"]
|
||||
autoplay = "gunOneHanded"
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("CapsuleShape3D_rk1ox")
|
||||
|
||||
[node name="HealthComponent" parent="." instance=ExtResource("3_g1ap4")]
|
||||
max_health = 300
|
||||
|
||||
[editable path="PlayerMesh"]
|
||||
[editable path="TargetMesh"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_resource type="Environment" load_steps=4 format=3 uid="uid://d2ahijqqspw5f"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://btdbu0qbe1646" path="res://environments/skyboxes/kloppenheim_06_puresky_2k.exr" id="1_k44rf"]
|
||||
[ext_resource type="Texture2D" uid="uid://odwhjbebqfcn" path="res://environments/skyboxes/kloppenheim_06_puresky_2k.exr" id="1_k44rf"]
|
||||
|
||||
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_7tawh"]
|
||||
panorama = ExtResource("1_k44rf")
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ offset_right = 288.0
|
|||
offset_bottom = 40.0
|
||||
size_flags_horizontal = 0
|
||||
mouse_filter = 2
|
||||
theme = SubResource("Theme_irfqb")
|
||||
theme_override_styles/fill = ExtResource("1_gh51l")
|
||||
value = 60.0
|
||||
show_percentage = false
|
||||
|
|
|
|||
|
|
@ -12,30 +12,80 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
extends Node2D
|
||||
extends Control
|
||||
|
||||
@export var attach_point : Node3D
|
||||
@export var player : Player
|
||||
@export var attach_point : Marker3D
|
||||
@export var healthbar_low_health_color : Color = Color(1 ,0 ,0, 0.78)
|
||||
@export var healthbar_mid_health_color : Color = Color(1, 1, 0, 0.78)
|
||||
@export var healthbar_high_health_color : Color = Color(0, 1, 0, 0.78)
|
||||
@export var iff_in_range_radius_ratio : float = 0.05
|
||||
|
||||
@onready var _player_name_label : Label = $Offset/VBoxContainer/PlayerNameLabel
|
||||
@onready var _health_bar : ProgressBar = $Offset/VBoxContainer/HealthBar
|
||||
@onready var _v_box_container : VBoxContainer = $Offset/VBoxContainer
|
||||
@onready var _iff_container : Control = $IFFContainer
|
||||
@onready var _iff_in_range_container : Control = $IFFContainer/IFFInRangeContainer
|
||||
@onready var _player_name_label : Control = $IFFContainer/IFFInRangeContainer/PlayerNameLabel
|
||||
@onready var _health_bar : ProgressBar = $IFFContainer/IFFInRangeContainer/HealthBar
|
||||
@onready var is_within_los : bool = false
|
||||
@onready var healthbar_fill_stylebox : StyleBoxFlat = _health_bar.get_theme_stylebox("fill")
|
||||
|
||||
func _ready() -> void:
|
||||
_player_name_label.text = player.name
|
||||
|
||||
func _process(_delta : float) -> void:
|
||||
var camera : Camera3D = get_viewport().get_camera_3d()
|
||||
if camera.is_position_behind(attach_point.global_position):
|
||||
_v_box_container.hide()
|
||||
# retrieve camera for current viewport
|
||||
var camera : Camera3D = get_viewport().get_camera_3d()
|
||||
|
||||
# if the player is NOT infront of the camera or camera does NOT have LOS to player
|
||||
if camera.is_position_behind(attach_point.global_position) or !is_within_los:
|
||||
_iff_container.hide() # hide the IFF and exit function
|
||||
return
|
||||
else:
|
||||
_v_box_container.show()
|
||||
_iff_container.show() # display the IFF
|
||||
|
||||
_player_name_label.text = player.nickname
|
||||
position = camera.unproject_position(attach_point.global_position)
|
||||
func _physics_process(_delta : float) -> void:
|
||||
# https://docs.godotengine.org/en/stable/tutorials/physics/ray-casting.html
|
||||
var camera : Camera3D = get_viewport().get_camera_3d()
|
||||
is_within_los = false # always initialise trace_success as false
|
||||
var space_state : PhysicsDirectSpaceState3D = camera.get_world_3d().direct_space_state
|
||||
# do a trace check from camera to towards the player
|
||||
var query : PhysicsRayQueryParameters3D = PhysicsRayQueryParameters3D.create(camera.global_position, attach_point.global_position)
|
||||
# exclude the camera owner nodes from intersecting with the trace check
|
||||
query.exclude = [camera.owner]
|
||||
# do trace check and store result
|
||||
var result : Dictionary = space_state.intersect_ray(query)
|
||||
# if a result was returned and the hit result is the player
|
||||
if result and result["collider"] == player:
|
||||
# the player is in camera LOS
|
||||
is_within_los = true
|
||||
|
||||
var new_iff_position : Vector2 = camera.unproject_position(attach_point.global_position) # get the screen location of the players head
|
||||
var viewport_size : Vector2 = get_viewport_rect().size
|
||||
position.x = clampf(position.x, 0, viewport_size.x - _v_box_container.size.x)
|
||||
position.y = clampf(position.y, _v_box_container.size.y, viewport_size.y)
|
||||
|
||||
# check if the unprojected point lies inside the viewport
|
||||
if !Rect2(Vector2(0, 0), viewport_size).has_point(new_iff_position):
|
||||
_iff_container.hide() # hide the IFF and exit function
|
||||
return
|
||||
|
||||
# if player is NOT in range to have its healthbar and name drawn
|
||||
if (new_iff_position - viewport_size / 2).length() > iff_in_range_radius_ratio * viewport_size.length():
|
||||
_iff_in_range_container.hide() # hide the in range IFF
|
||||
else:
|
||||
_iff_in_range_container.show()
|
||||
|
||||
new_iff_position.y -= _iff_container.size.y # move the IFF up so the bottom of it is at the players head
|
||||
new_iff_position.x -= _iff_container.size.x / 2 # move the IFF left so it's centered horizontally above players head
|
||||
|
||||
position = new_iff_position # set the position of the IFF
|
||||
|
||||
func _update_health_bar(health : float) -> void:
|
||||
_health_bar.value = health
|
||||
|
||||
# modify health_box stylebox depending health value
|
||||
if health < 75 and health > 40:
|
||||
healthbar_fill_stylebox.bg_color = healthbar_mid_health_color
|
||||
elif health <= 40:
|
||||
healthbar_fill_stylebox.bg_color = healthbar_low_health_color
|
||||
else:
|
||||
healthbar_fill_stylebox.bg_color = healthbar_high_health_color
|
||||
|
||||
func _on_health_changed(new_health : float) -> void:
|
||||
_update_health_bar(new_health)
|
||||
|
|
|
|||
|
|
@ -1,26 +1,52 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dsysi2rd3bu76"]
|
||||
|
||||
[ext_resource type="Script" path="res://interfaces/hud/iff.gd" id="1_75yi1"]
|
||||
[ext_resource type="StyleBox" uid="uid://cl7dmo2bg4153" path="res://interfaces/hud/healthbar_fill_style.tres" id="2_x7k8o"]
|
||||
[ext_resource type="StyleBox" uid="uid://cgv081wfih7la" path="res://interfaces/hud/iff_healthbar_fill_style.tres" id="2_frxvy"]
|
||||
|
||||
[node name="IFF" type="Node2D"]
|
||||
[node name="IFF" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_75yi1")
|
||||
|
||||
[node name="Offset" type="Node2D" parent="."]
|
||||
position = Vector2(0, -32)
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Offset"]
|
||||
offset_right = 100.0
|
||||
offset_bottom = 40.0
|
||||
[node name="IFFContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_right = 63.0
|
||||
offset_bottom = 42.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="PlayerNameLabel" type="Label" parent="Offset/VBoxContainer"]
|
||||
[node name="IFFInRangeContainer" type="Control" parent="IFFContainer"]
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="PlayerNameLabel" type="Label" parent="IFFContainer/IFFInRangeContainer"]
|
||||
layout_mode = 2
|
||||
offset_right = 63.0
|
||||
offset_bottom = 17.0
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Player"
|
||||
horizontal_alignment = 1
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="Offset/VBoxContainer"]
|
||||
[node name="HealthBar" type="ProgressBar" parent="IFFContainer/IFFInRangeContainer"]
|
||||
layout_mode = 2
|
||||
offset_top = 20.0
|
||||
offset_right = 63.0
|
||||
offset_bottom = 24.0
|
||||
mouse_filter = 2
|
||||
theme_override_styles/fill = ExtResource("2_x7k8o")
|
||||
theme_override_styles/fill = ExtResource("2_frxvy")
|
||||
value = 60.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="Chevron" type="Label" parent="IFFContainer"]
|
||||
layout_direction = 2
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 1
|
||||
theme_override_colors/font_color = Color(1, 0, 0, 0.2)
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 0.2)
|
||||
theme_override_constants/outline_size = 3
|
||||
theme_override_constants/line_spacing = -20
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "▼"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 2
|
||||
|
|
|
|||
9
interfaces/hud/iff_healthbar_fill_style.tres
Normal file
9
interfaces/hud/iff_healthbar_fill_style.tres
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[gd_resource type="StyleBoxFlat" format=3 uid="uid://cgv081wfih7la"]
|
||||
|
||||
[resource]
|
||||
bg_color = Color(1, 0, 0, 0.25)
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
anti_aliasing = false
|
||||
|
|
@ -86,7 +86,7 @@ func add_flag() -> void:
|
|||
|
||||
func _exit_tree() -> void:
|
||||
if multiplayer.is_server():
|
||||
multiplayer.peer_connected.disconnect(add_player)
|
||||
#multiplayer.peer_connected.disconnect(add_player)
|
||||
multiplayer.peer_disconnected.disconnect(remove_player)
|
||||
"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue