added ladder functionality

This commit is contained in:
leca 2024-03-02 03:46:17 +03:00
parent 63d3d8cc44
commit 6d8e66815e
6 changed files with 89 additions and 50 deletions

View File

@ -1,10 +1,10 @@
[gd_scene load_steps=13 format=3 uid="uid://gxfhitfre2fj"]
[ext_resource type="Texture2D" uid="uid://vnk3r1p4ao3n" path="res://textures/prototype-textures/Prototype_symbol_cross_32x32px.png" id="1_g1v70"]
[ext_resource type="Texture2D" uid="uid://pmm3aspqx5fs" path="res://textures/logo/health.svg" id="1_ts1uf"]
[ext_resource type="Texture2D" uid="uid://djq4ll0v3wx3w" path="res://textures/logo/shield.svg" id="2_ijndi"]
[ext_resource type="Texture2D" uid="uid://brs0gwps35l5k" path="res://textures/logo/magazine.svg" id="3_ssnuf"]
[ext_resource type="Texture2D" uid="uid://ob5ueh5eqfn7" path="res://textures/logo/ammo.svg" id="4_f070v"]
[ext_resource type="Texture2D" uid="uid://c4pah1vj0aa4x" path="res://textures/prototype-textures/Prototype_symbol_cross_32x32px.png" id="1_g1v70"]
[ext_resource type="Texture2D" uid="uid://na1y6c7osyj2" path="res://textures/logo/health.svg" id="1_ts1uf"]
[ext_resource type="Texture2D" uid="uid://cxpljra1na1p8" path="res://textures/logo/shield.svg" id="2_ijndi"]
[ext_resource type="Texture2D" uid="uid://d1i1fgjbpwped" path="res://textures/logo/magazine.svg" id="3_ssnuf"]
[ext_resource type="Texture2D" uid="uid://bmuo2tbe3r8ih" path="res://textures/logo/ammo.svg" id="4_f070v"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ryudk"]
bg_color = Color(1, 1, 1, 1)
@ -36,7 +36,7 @@ grow_vertical = 2
mouse_filter = 2
metadata/_edit_use_anchors_ = true
[node name="hud" type="Control" parent="."]
[node name="health_and_ammo_display" type="Control" parent="."]
custom_minimum_size = Vector2(200, 70)
layout_mode = 1
anchors_preset = 7
@ -51,7 +51,7 @@ offset_bottom = -12.0
grow_horizontal = 2
grow_vertical = 0
[node name="pipe" type="Panel" parent="hud"]
[node name="pipe" type="Panel" parent="health_and_ammo_display"]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.5
@ -65,7 +65,7 @@ grow_horizontal = 2
grow_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_ryudk")
[node name="healthdisplay" type="Control" parent="hud"]
[node name="healthdisplay" type="Control" parent="health_and_ammo_display"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
@ -79,7 +79,7 @@ offset_bottom = -45.0
grow_horizontal = 2
grow_vertical = 0
[node name="text" type="Label" parent="hud/healthdisplay"]
[node name="text" type="Label" parent="health_and_ammo_display/healthdisplay"]
layout_mode = 1
anchors_preset = 6
anchor_left = 1.0
@ -94,7 +94,7 @@ grow_vertical = 2
text = "100
"
[node name="logo" type="Panel" parent="hud/healthdisplay"]
[node name="logo" type="Panel" parent="health_and_ammo_display/healthdisplay"]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
@ -104,7 +104,7 @@ offset_right = 25.0
grow_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxTexture_u8rhl")
[node name="armordisplay" type="Control" parent="hud"]
[node name="armordisplay" type="Control" parent="health_and_ammo_display"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
@ -118,7 +118,7 @@ offset_bottom = -10.0
grow_horizontal = 2
grow_vertical = 0
[node name="text" type="Label" parent="hud/armordisplay"]
[node name="text" type="Label" parent="health_and_ammo_display/armordisplay"]
layout_mode = 1
anchors_preset = 6
anchor_left = 1.0
@ -133,7 +133,7 @@ grow_vertical = 2
text = "100
"
[node name="logo" type="Panel" parent="hud/armordisplay"]
[node name="logo" type="Panel" parent="health_and_ammo_display/armordisplay"]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
@ -143,7 +143,7 @@ offset_right = 25.0
grow_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxTexture_n5sx0")
[node name="magazinedisplay" type="Control" parent="hud"]
[node name="magazinedisplay" type="Control" parent="health_and_ammo_display"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
@ -157,7 +157,7 @@ offset_bottom = -45.0
grow_horizontal = 2
grow_vertical = 0
[node name="text" type="Label" parent="hud/magazinedisplay"]
[node name="text" type="Label" parent="health_and_ammo_display/magazinedisplay"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
@ -169,7 +169,7 @@ grow_vertical = 2
text = "100
"
[node name="logo" type="Panel" parent="hud/magazinedisplay"]
[node name="logo" type="Panel" parent="health_and_ammo_display/magazinedisplay"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
@ -182,7 +182,7 @@ grow_horizontal = 0
grow_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxTexture_w337q")
[node name="ammodisplay" type="Control" parent="hud"]
[node name="ammodisplay" type="Control" parent="health_and_ammo_display"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
@ -196,7 +196,7 @@ offset_bottom = -10.0
grow_horizontal = 2
grow_vertical = 0
[node name="text" type="Label" parent="hud/ammodisplay"]
[node name="text" type="Label" parent="health_and_ammo_display/ammodisplay"]
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
@ -208,7 +208,7 @@ grow_vertical = 2
text = "100
"
[node name="logo" type="Panel" parent="hud/ammodisplay"]
[node name="logo" type="Panel" parent="health_and_ammo_display/ammodisplay"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0

View File

@ -3,7 +3,7 @@
[ext_resource type="Script" path="res://scripts/ConnectButton.gd" id="1_nhpm2"]
[ext_resource type="Script" path="res://scripts/TaskPanelButton.gd" id="1_yn6yn"]
[ext_resource type="Script" path="res://scripts/Nickname.gd" id="2_5xejq"]
[ext_resource type="Texture2D" uid="uid://dc6j05jqjwuo6" path="res://icon.png" id="4_ps4pi"]
[ext_resource type="Texture2D" uid="uid://bxmfgknljdw65" path="res://icon.svg" id="4_j2ki1"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8m8o7"]
bg_color = Color(0.541176, 0.0352941, 0.627451, 1)
@ -223,5 +223,5 @@ grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_8m8o7")
[node name="Icon" type="Sprite2D" parent="Panel"]
position = Vector2(45, 20)
texture = ExtResource("4_ps4pi")
position = Vector2(53, 19)
texture = ExtResource("4_j2ki1")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://dx2v4x2jey55t"]
[gd_scene load_steps=15 format=3 uid="uid://dx2v4x2jey55t"]
[ext_resource type="Texture2D" uid="uid://c88oa7ckhmvoh" path="res://textures/prototype-textures/Prototype_grey_32x32px.png" id="1_87a53"]
[ext_resource type="Material" uid="uid://bm7dpv2ymo0s" path="res://textures/materials/black.material" id="2_acmnt"]
@ -7,8 +7,7 @@
[ext_resource type="PackedScene" uid="uid://833q6upr0s1k" path="res://scenes/special/spawnpoint.tscn" id="5_4t8n8"]
[ext_resource type="Material" uid="uid://lh788k850e21" path="res://textures/materials/red.material" id="5_mri33"]
[ext_resource type="Material" path="res://textures/materials/orange.res" id="6_n8h4m"]
[ext_resource type="Material" uid="uid://bswen72o66of2" path="res://textures/materials/blue.material" id="7_gt32y"]
[ext_resource type="ArrayMesh" uid="uid://bal0u14qxmjfb" path="res://models/ladder.obj" id="8_b1h5c"]
[ext_resource type="PackedScene" uid="uid://dgctb724je8cj" path="res://scenes/models/ladder.tscn" id="9_ix4hd"]
[ext_resource type="PackedScene" uid="uid://ut1ssyeu88ui" path="res://scenes/models/target.tscn" id="10_cjpfc"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rbwrc"]
@ -230,6 +229,11 @@ sides = 12
smooth_faces = false
material = ExtResource("6_n8h4m")
[node name="OmniLight3D" type="OmniLight3D" parent="CSGCombiner3D/street/king_of_the_hill/CSGCylinder3D10"]
transform = Transform3D(0.1, 0, 0, 0, 0.0370372, 0, 0, 0, 0.1, 0, 0.0374591, 0)
light_energy = 14.419
omni_range = 30.468
[node name="tower" type="CSGMesh3D" parent="CSGCombiner3D/street"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
@ -256,21 +260,6 @@ operation = 2
size = Vector3(0.26, 0.15, 0.253418)
material = ExtResource("3_1ncrc")
[node name="ladder" type="MeshInstance3D" parent="CSGCombiner3D/street/tower"]
transform = Transform3D(-3.93403e-09, 0, -0.09, 0, 0.09, 0, 0.09, 0, -3.93403e-09, -1.16555, -0.312215, -1.31007)
material_override = ExtResource("7_gt32y")
mesh = ExtResource("8_b1h5c")
[node name="ladder2" type="MeshInstance3D" parent="CSGCombiner3D/street/tower"]
transform = Transform3D(-3.93403e-09, 0, -0.09, 0, 0.09, 0, 0.09, 0, -3.93403e-09, -1.16543, -0.190152, -1.31007)
material_override = ExtResource("7_gt32y")
mesh = ExtResource("8_b1h5c")
[node name="ladder3" type="MeshInstance3D" parent="CSGCombiner3D/street/tower"]
transform = Transform3D(-3.93403e-09, 0, -0.09, 0, 0.09, 0, 0.09, 0, -3.93403e-09, -1.16543, -0.0816341, -1.31007)
material_override = ExtResource("7_gt32y")
mesh = ExtResource("8_b1h5c")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.00940726, 0.999898, -0.0107741, 0.0036501, 0.0107402, 0.999936, 0.999949, -0.00944598, -0.00354869, -44.6165, 55.8676, -6.56245e-06)
light_angular_distance = 11.76
@ -288,10 +277,28 @@ team = 1
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -48.5284, 20.414, -22.8886)
[node name="target" parent="." instance=ExtResource("10_cjpfc")]
transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, -51.7796, 20.0206, -41.7327)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -51.6507, 20.0206, -41.6927)
[node name="target2" parent="." instance=ExtResource("10_cjpfc")]
transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, -48.9129, 20.0206, -41.368)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -48.8073, 20.0206, -40.9023)
[node name="target3" parent="." instance=ExtResource("10_cjpfc")]
transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, -45.7556, 20.0206, -41.6981)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -45.801, 20.0206, -41.3646)
[node name="ladder" parent="." instance=ExtResource("9_ix4hd")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -67.5251, 20.0388, -23.7606)
[node name="ladder2" parent="." instance=ExtResource("9_ix4hd")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -67.5251, 21.3906, -23.7612)
[node name="ladder3" parent="." instance=ExtResource("9_ix4hd")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -67.5251, 22.7609, -23.7643)
[node name="ladder4" parent="." instance=ExtResource("9_ix4hd")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -67.5251, 24.0983, -23.7605)
[node name="ladder5" parent="." instance=ExtResource("9_ix4hd")]
transform = Transform3D(2.98023e-08, 0, 1, 0, 1, 0, -1, 0, 2.98023e-08, -67.525, 25.45, -23.761)
[node name="ladder6" parent="." instance=ExtResource("9_ix4hd")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -67.525, 26.817, -23.762)

24
scenes/models/ladder.tscn Normal file
View File

@ -0,0 +1,24 @@
[gd_scene load_steps=4 format=3 uid="uid://dgctb724je8cj"]
[ext_resource type="ArrayMesh" uid="uid://bal0u14qxmjfb" path="res://models/ladder.obj" id="1_57ly1"]
[sub_resource type="BoxShape3D" id="BoxShape3D_10q5c"]
size = Vector3(0.894531, 1.39441, 0.121826)
[sub_resource type="BoxShape3D" id="BoxShape3D_8igfg"]
size = Vector3(0.890503, 1.36963, 1)
[node name="ladder" type="StaticBody3D"]
[node name="shape" type="MeshInstance3D" parent="."]
mesh = ExtResource("1_57ly1")
[node name="collider" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.000976562, 0.667726, 0.00769043)
shape = SubResource("BoxShape3D_10q5c")
[node name="active_area" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0043335, 0.679118, 0.57602)
visible = false
shape = SubResource("BoxShape3D_8igfg")
disabled = true

View File

@ -10,7 +10,6 @@ size = Vector3(0.624695, 0.569092, 0.129181)
size = Vector3(0.877014, 1.24915, 0.123413)
[node name="target" type="StaticBody3D"]
transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0)
script = ExtResource("1_hd3f1")
[node name="Mesh" type="MeshInstance3D" parent="."]

View File

@ -42,6 +42,7 @@ var jump = 16
var gravity = 9.8
var acceleration = 2.5
var inertia = 20
var climbing = false
var game_settings
var client_settings
@ -181,7 +182,6 @@ func _unhandled_input(event):
properties["current_weapon"] = find_current_weapon_by_number(weapon_number)
if (!properties["offline_mode"]): Networking.change_weapon.rpc_id(1, multiplayer.get_unique_id(), properties["current_weapon"]["number"])
change_weapon(properties["current_weapon"]["number"])
if event is InputEventMouseMotion:
head.rotate_y(-event.relative.x * SENSETIVITY)
@ -212,11 +212,14 @@ func _physics_process(delta):
if direction:
velocity.x = lerp(velocity.x, direction.x * speed, delta * acceleration)
velocity.z = lerp(velocity.z, direction.z * speed, delta * acceleration)
if (climbing):
print(str(input_dir))
velocity.y = -input_dir.y * jump / 2 if input_dir.x == 0 else abs(input_dir.x) * jump / 2
else:
if is_on_floor():
velocity.x = lerp(velocity.x, direction.x * speed * 0.5, delta * inertia)
velocity.z = lerp(velocity.z, direction.z * speed * 0.5, delta * inertia)
else:
elif not is_on_floor() and not climbing:
velocity.x = lerp(velocity.x, direction.x * speed * 0.5, delta)
velocity.z = lerp(velocity.z, direction.z * speed * 0.5, delta)
if is_on_floor():
@ -231,9 +234,16 @@ func _physics_process(delta):
velocity.x = lerp(velocity.x, direction.x * speed, delta)
velocity.z = lerp(velocity.z, direction.z * speed, delta)
move_and_slide()
for index in get_slide_collision_count():
var collision := get_slide_collision(index)
var body := collision.get_collider()
if ("ladder" in body.name):
climbing = true
else:
climbing = false
#print("Collided with: " + body.name)
if (!multiplayer.is_server()):
if (!properties["offline_mode"]): Networking.sync_client.rpc_id(1, multiplayer.get_unique_id(), $".".position, {"y": head.rotation.y, "x": camera.rotation.x})
Networking.sync_client.rpc_id(1, multiplayer.get_unique_id(), $".".position, {"y": head.rotation.y, "x": camera.rotation.x})
#print("I am " + $"..".name +", belonging of " + str(multiplayer.get_unique_id()) + ", with internal ID: " + str(properties["internal_id"]))
@rpc ("authority", "call_remote", "unreliable")
@ -252,7 +262,6 @@ func set_hp(hp):
@rpc ("authority", "call_remote", "reliable")
func set_game_settings(s):
#if(!properties["is_playable"]): return
game_settings = s
gravity = game_settings["moving"]["gravity"]
walk = game_settings["moving"]["walk"]
@ -264,7 +273,7 @@ func set_game_settings(s):
@rpc ("authority", "call_remote", "reliable")
func teleport(pos):
$".".position = pos
position = pos
@rpc ("authority", "call_remote", "reliable")
func change_weapon_puppet(i_id, new_weapon_number):