mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-14 07:56:32 +00:00
✨ Implement friend and foe IFF color change and fix bugs
This commit is contained in:
parent
4cead7d985
commit
4c44dc7b30
5 changed files with 43 additions and 9 deletions
|
|
@ -37,10 +37,19 @@ func _process(_delta : float) -> void:
|
|||
|
||||
# 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
|
||||
_iff_container.hide()
|
||||
else:
|
||||
_iff_container.show() # display the IFF
|
||||
_iff_container.show()
|
||||
|
||||
# Show the correct IFF based on whether the player we're looking at belongs is a friend or a foe
|
||||
# in other words if their team_ids are the same as the "pawn" player
|
||||
if player.pawn_player != null:
|
||||
if player.pawn_player.team_id == player.team_id:
|
||||
%FoeChevron.hide()
|
||||
%FriendChevron.show()
|
||||
else:
|
||||
%FoeChevron.show()
|
||||
%FriendChevron.hide()
|
||||
|
||||
func _physics_process(_delta : float) -> void:
|
||||
# https://docs.godotengine.org/en/stable/tutorials/physics/ray-casting.html
|
||||
|
|
@ -48,9 +57,12 @@ func _physics_process(_delta : float) -> void:
|
|||
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)
|
||||
var query : PhysicsRayQueryParameters3D = PhysicsRayQueryParameters3D.create(camera.global_position, player.global_position)
|
||||
# only collide with Layer 1 (objects) and Layer 32 (terrain/structures)
|
||||
query.collision_mask = 0b10000000_00000000_00000000_00000001
|
||||
# exclude the camera owner nodes from intersecting with the trace check
|
||||
query.exclude = [camera.owner]
|
||||
if player.pawn_player:
|
||||
query.exclude = [player.pawn_player]
|
||||
# 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
|
||||
|
|
@ -74,7 +86,6 @@ func _physics_process(_delta : float) -> void:
|
|||
|
||||
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:
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ theme_override_styles/fill = ExtResource("2_e3xla")
|
|||
value = 60.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="Chevron" type="Label" parent="IFFContainer"]
|
||||
[node name="FoeChevron" type="Label" parent="IFFContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_direction = 2
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 1
|
||||
|
|
@ -52,3 +54,18 @@ theme_override_font_sizes/font_size = 14
|
|||
text = "▼"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 2
|
||||
|
||||
[node name="FriendChevron" type="Label" parent="IFFContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_direction = 2
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 1
|
||||
theme_override_colors/font_color = Color(0, 1, 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue