IFF Updates

This commit is contained in:
Karan Codes 2024-04-19 20:43:55 +00:00 committed by anyreso
parent d6d2bf7866
commit 71ff1e1622
14 changed files with 261 additions and 99 deletions

View file

@ -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()

View file

@ -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")