mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-15 08:24:48 +00:00
Add Flagstand prop and fix walking on non-terrain surfaces
This commit is contained in:
parent
5a3c52c26d
commit
06eeff520d
6 changed files with 49 additions and 40 deletions
|
|
@ -39,7 +39,7 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
|||
@onready var input : PlayerInput = $PlayerInput
|
||||
@onready var camera : Camera3D = $Smoothing/SpringArm3D/Camera3D
|
||||
@onready var hud : CanvasLayer = $HUD
|
||||
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
|
||||
@onready var walkable_surface_sensor : ShapeCast3D = $WalkableSurfaceSensor
|
||||
@onready var weapon : Node3D = $Smoothing/SpringArm3D/Inventory/SpaceGun
|
||||
@onready var animation_player : AnimationPlayer = $AnimationPlayer
|
||||
@onready var health_component : Area3D = $HealthComponent
|
||||
|
|
@ -112,12 +112,7 @@ func _throw_flag() -> void:
|
|||
flag_carry_component.throw(linear_velocity, self)
|
||||
|
||||
func is_on_floor() -> bool:
|
||||
if shape_cast.is_colliding():
|
||||
for i in shape_cast.get_collision_count():
|
||||
var collider : Object = shape_cast.get_collider(i)
|
||||
if collider is Terrain3D:
|
||||
return true
|
||||
return false
|
||||
return walkable_surface_sensor.is_colliding()
|
||||
|
||||
func _is_skiing() -> bool:
|
||||
return input.skiing
|
||||
|
|
@ -185,7 +180,7 @@ func _handle_movement() -> void:
|
|||
if is_on_floor():
|
||||
if not _direction.is_zero_approx() and not _is_skiing():
|
||||
# retrieve collision normal
|
||||
var normal : Vector3 = shape_cast.get_collision_normal(0)
|
||||
var normal : Vector3 = walkable_surface_sensor.get_collision_normal(0)
|
||||
# calculate the angle between the ground normal and the up vector
|
||||
var slope_angle : float = rad_to_deg(acos(normal.dot(Vector3.UP)))
|
||||
# check if the slope angle exceeds the maximum slope angle
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=42 format=3 uid="uid://cbhx1xme0sb7k"]
|
||||
[gd_scene load_steps=41 format=3 uid="uid://cbhx1xme0sb7k"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/player/player.gd" id="1_mk68k"]
|
||||
[ext_resource type="PackedScene" uid="uid://drbefw6akui2v" path="res://entities/player/assets/vanguard.tscn" id="2_beyex"]
|
||||
|
|
@ -21,10 +21,7 @@ resource_local_to_scene = true
|
|||
bounce = 1.0
|
||||
absorbent = true
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1hdqa"]
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_vmqfq"]
|
||||
material = SubResource("StandardMaterial3D_1hdqa")
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_yvu24"]
|
||||
radius = 0.25
|
||||
|
||||
[sub_resource type="Animation" id="Animation_yqgrk"]
|
||||
|
|
@ -208,19 +205,14 @@ script = ExtResource("1_mk68k")
|
|||
iff = NodePath("Smoothing/ThirdPerson/IFF")
|
||||
jump_height = 1.5
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
visible = false
|
||||
mesh = SubResource("CapsuleMesh_vmqfq")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = ExtResource("2_vjqny")
|
||||
|
||||
[node name="ShapeCast3D" type="ShapeCast3D" parent="."]
|
||||
transform = Transform3D(1.05, 0, 0, 0, 1.05, 0, 0, 0, 1.05, 0, 0, 0)
|
||||
shape = ExtResource("2_vjqny")
|
||||
[node name="WalkableSurfaceSensor" type="ShapeCast3D" parent="."]
|
||||
transform = Transform3D(1.05, 0, 0, 0, 1.05, 0, 0, 0, 1.05, 0, -0.85, 0)
|
||||
shape = SubResource("SphereShape3D_yvu24")
|
||||
target_position = Vector3(0, 0, 0)
|
||||
collision_mask = 2147483648
|
||||
collide_with_areas = true
|
||||
|
||||
[node name="Sensor" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue