mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-15 16:34:48 +00:00
Make the Flag entity smooth as silk
This commit is contained in:
parent
a18a9ea6f3
commit
323c5f1c99
7 changed files with 43 additions and 32 deletions
|
|
@ -9,12 +9,14 @@ signal regrabbed
|
|||
signal dropped
|
||||
|
||||
var last_carrier : Player = null
|
||||
@onready var _mesh : Node = $Smoothing/Mesh
|
||||
|
||||
func can_be_grabbed() -> bool:
|
||||
return flag_state != FlagState.FLAG_STATE_TAKEN
|
||||
|
||||
func grab(grabber : Player) -> void:
|
||||
if flag_state != FlagState.FLAG_STATE_TAKEN:
|
||||
_mesh.hide()
|
||||
flag_state = FlagState.FLAG_STATE_TAKEN
|
||||
if (last_carrier == null) or (grabber != last_carrier):
|
||||
grabbed.emit(grabber)
|
||||
|
|
@ -24,6 +26,7 @@ func grab(grabber : Player) -> void:
|
|||
|
||||
func drop() -> void:
|
||||
if flag_state == FlagState.FLAG_STATE_TAKEN:
|
||||
_mesh.show()
|
||||
flag_state = FlagState.FLAG_STATE_DROPPED
|
||||
dropped.emit()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://c88l3h0ph00c7"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://c88l3h0ph00c7"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/flag/flag.gd" id="1_y7d3d"]
|
||||
[ext_resource type="Script" path="res://addons/smoothing/smoothing.gd" id="2_es4ce"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3l7fvbdg6m5g" 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"]
|
||||
|
||||
|
|
@ -20,6 +21,9 @@ properties/1/replication_mode = 1
|
|||
properties/2/path = NodePath(".:flag_state")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 2
|
||||
properties/3/path = NodePath("Smoothing/Mesh:visible")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 2
|
||||
|
||||
[node name="Flag" type="RigidBody3D"]
|
||||
collision_layer = 8
|
||||
|
|
@ -34,9 +38,6 @@ center_of_mass = Vector3(0, 0.5, 0)
|
|||
continuous_cd = true
|
||||
script = ExtResource("1_y7d3d")
|
||||
|
||||
[node name="Mesh" parent="." instance=ExtResource("2_i78em")]
|
||||
transform = Transform3D(0.33, 0, 0, 0, 0.421029, 0, 0, 0, 0.33, 0, 0.0744106, 0)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("BoxShape3D_fkf1k")
|
||||
|
|
@ -44,8 +45,14 @@ shape = SubResource("BoxShape3D_fkf1k")
|
|||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_lpijf")
|
||||
|
||||
[node name="WaypointAttachment" type="Marker3D" parent="."]
|
||||
[node name="Smoothing" type="Node3D" parent="."]
|
||||
script = ExtResource("2_es4ce")
|
||||
|
||||
[node name="Waypoint" parent="WaypointAttachment" node_paths=PackedStringArray("attach_point", "flag") instance=ExtResource("3_tu6jg")]
|
||||
[node name="WaypointAttachment" type="Marker3D" parent="Smoothing"]
|
||||
|
||||
[node name="Waypoint" parent="Smoothing/WaypointAttachment" node_paths=PackedStringArray("attach_point", "flag") instance=ExtResource("3_tu6jg")]
|
||||
attach_point = NodePath("..")
|
||||
flag = NodePath("../..")
|
||||
flag = NodePath("../../..")
|
||||
|
||||
[node name="Mesh" parent="Smoothing" instance=ExtResource("2_i78em")]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.0744106, 0)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
# 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
|
||||
|
|
@ -32,15 +32,15 @@ func _process(_delta : float) -> void:
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue