Compare commits
11 commits
cf5eb5ae6e
...
f1a4ad761c
| Author | SHA1 | Date | |
|---|---|---|---|
| f1a4ad761c | |||
| e16f87cbfa | |||
| 20d1f62a7d | |||
| bc88fed830 | |||
| 7ba423e6c5 | |||
| 5b7ab7811e | |||
| 1e4aeddbb5 | |||
| f22364ce39 | |||
| 907508c4eb | |||
| 10dd8ce719 | |||
| f16e26c981 |
12 changed files with 356 additions and 40 deletions
|
|
@ -2,8 +2,6 @@ class_name Ball extends "gear.gd"
|
|||
|
||||
func gear_name():
|
||||
return "Ball"
|
||||
func gear_id():
|
||||
return 1
|
||||
func continuous():
|
||||
return false
|
||||
|
||||
|
|
|
|||
|
|
@ -1,43 +1,47 @@
|
|||
@icon("./gear.png")
|
||||
class_name Gear extends Node3D
|
||||
|
||||
var idle_basis = Basis(
|
||||
Vector3(1, 0, 0),
|
||||
Vector3(0, 1, 0),
|
||||
Vector3(0, 0, 1))
|
||||
var use_basis = Basis(
|
||||
Vector3(1, 0, 0),
|
||||
Vector3(0, 0, -1),
|
||||
Vector3(0, 1, 0))
|
||||
var pickup_basis = idle_basis
|
||||
|
||||
func gear_name():
|
||||
return "Gear"
|
||||
func gear_id():
|
||||
return 0
|
||||
func model_file():
|
||||
return "hammer.glb"
|
||||
func continuous():
|
||||
return false
|
||||
func idle_basis():
|
||||
return Basis(
|
||||
Vector3(1, 0, 0),
|
||||
Vector3(0, 1, 0),
|
||||
Vector3(0, 0, 1))
|
||||
func use_basis():
|
||||
return Basis(
|
||||
Vector3(1, 0, 0),
|
||||
Vector3(0, 0, -1),
|
||||
Vector3(0, 1, 0))
|
||||
func pickup_basis():
|
||||
return idle_basis()
|
||||
|
||||
# this can be redefined to make a custom
|
||||
# gear mesh, e.g. a SphereMesh
|
||||
func use(player):
|
||||
basis = use_basis
|
||||
basis = use_basis()
|
||||
$Timer.start()
|
||||
on_use(player)
|
||||
|
||||
func unequip(player):
|
||||
on_unequip(player)
|
||||
|
||||
func on_use(_player):
|
||||
pass
|
||||
|
||||
func on_unequip(_player):
|
||||
pass
|
||||
|
||||
func on_ready():
|
||||
pass
|
||||
|
||||
func _on_timer_timeout():
|
||||
basis = idle_basis
|
||||
basis = idle_basis()
|
||||
|
||||
func _ready():
|
||||
basis = idle_basis
|
||||
basis = idle_basis()
|
||||
if get_parent() is GearPickup:
|
||||
basis = pickup_basis
|
||||
basis = pickup_basis()
|
||||
on_ready()
|
||||
|
|
|
|||
62
gears/geep.gd
Normal file
62
gears/geep.gd
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
class_name Geep extends "gear.gd"
|
||||
|
||||
func gear_name():
|
||||
return "Geep"
|
||||
func continuous():
|
||||
return false
|
||||
func use_basis():
|
||||
return idle_basis()
|
||||
|
||||
# multiplier of player's speed
|
||||
const speed = 2
|
||||
# how far the vehicle lifts the player off the ground
|
||||
const lift = 2
|
||||
|
||||
var box = null
|
||||
var driver = null
|
||||
var active = false
|
||||
|
||||
func init_driver(player):
|
||||
driver = player
|
||||
if not box:
|
||||
box = Vector3(driver.get_node("CollisionShape3D").shape.size)
|
||||
|
||||
func mount():
|
||||
active = true
|
||||
position = Vector3(-driver.get_node("Pivot/Container").position)
|
||||
position.y += 1
|
||||
driver.message(
|
||||
"Press [%s] to exit the Geep"
|
||||
% Util.input_action_string("gear_use"))
|
||||
driver.get_node("CameraGimbal").position.y += lift
|
||||
driver.get_node("Pivot/Mesh").position.y += lift
|
||||
driver.get_node("CollisionShape3D").shape.size = $GearMesh/Vehicle/CollisionShape3D.shape.size
|
||||
driver.protected = true
|
||||
driver.suspended = true
|
||||
|
||||
func unmount():
|
||||
active = false
|
||||
position = Vector3.ZERO
|
||||
driver.message("")
|
||||
driver.get_node("CameraGimbal").position = Vector3.ZERO
|
||||
driver.get_node("Pivot/Mesh").position = Vector3.ZERO
|
||||
driver.get_node("CollisionShape3D").shape.size = box
|
||||
driver.protected = false
|
||||
driver.suspended = false
|
||||
|
||||
func on_use(player):
|
||||
init_driver(player)
|
||||
if active:
|
||||
unmount()
|
||||
else:
|
||||
mount()
|
||||
|
||||
func on_unequip(player):
|
||||
init_driver(player)
|
||||
unmount()
|
||||
|
||||
func _physics_process(_delta):
|
||||
if not active:
|
||||
return
|
||||
|
||||
driver.move_player(0, -speed)
|
||||
87
gears/geep.tscn
Normal file
87
gears/geep.tscn
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://d3k7b6o56ue5k"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://fljad0m3jlt0" path="res://gears/geep.gd" id="1_8skgp"]
|
||||
[ext_resource type="Material" uid="uid://dpacu3e7vsks5" path="res://gears/geep_body.tres" id="2_rhiad"]
|
||||
[ext_resource type="Material" uid="uid://bt5aat64e478k" path="res://gears/geep_wheel.tres" id="3_lrfuo"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_lrfuo"]
|
||||
size = Vector3(3, 3, 6)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_rhiad"]
|
||||
material = ExtResource("2_rhiad")
|
||||
size = Vector3(3, 0.5, 6)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_kyikt"]
|
||||
material = ExtResource("2_rhiad")
|
||||
size = Vector3(0.5, 1.75, 6)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_wm067"]
|
||||
material = ExtResource("2_rhiad")
|
||||
size = Vector3(3, 2, 2.5)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_lrfuo"]
|
||||
material = ExtResource("2_rhiad")
|
||||
size = Vector3(3, 2, 0.5)
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_lrfuo"]
|
||||
material = ExtResource("3_lrfuo")
|
||||
top_radius = 1.0
|
||||
bottom_radius = 1.0
|
||||
height = 0.25
|
||||
|
||||
[node name="Gear" type="Node3D"]
|
||||
rotation_edit_mode = 2
|
||||
script = ExtResource("1_8skgp")
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="GearMesh" type="Node3D" parent="."]
|
||||
|
||||
[node name="Vehicle" type="StaticBody3D" parent="GearMesh"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1.0000001, 0, 0, 0, 1.0000001, 0, 0, 0)
|
||||
collision_layer = 4
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
||||
shape = SubResource("BoxShape3D_lrfuo")
|
||||
|
||||
[node name="BaseMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9997004, 0)
|
||||
mesh = SubResource("BoxMesh_rhiad")
|
||||
|
||||
[node name="LeftSideMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, -1.25, 2.1247003, 0)
|
||||
mesh = SubResource("BoxMesh_kyikt")
|
||||
skeleton = NodePath("")
|
||||
|
||||
[node name="RightSideMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, 1.25, 2.1247003, 0)
|
||||
mesh = SubResource("BoxMesh_kyikt")
|
||||
skeleton = NodePath("")
|
||||
|
||||
[node name="BonnetMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.9997005, -1.75)
|
||||
mesh = SubResource("BoxMesh_wm067")
|
||||
|
||||
[node name="TailgateMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.9997005, 2.75)
|
||||
mesh = SubResource("BoxMesh_lrfuo")
|
||||
|
||||
[node name="WheelFLMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, 1.65, 1, 2)
|
||||
mesh = SubResource("CylinderMesh_lrfuo")
|
||||
|
||||
[node name="WheelFRMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, -1.65, 1, 2)
|
||||
mesh = SubResource("CylinderMesh_lrfuo")
|
||||
|
||||
[node name="WheelBLMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, 1.65, 1, -2)
|
||||
mesh = SubResource("CylinderMesh_lrfuo")
|
||||
|
||||
[node name="WheelBRMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, -1.65, 1, -2)
|
||||
mesh = SubResource("CylinderMesh_lrfuo")
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||
4
gears/geep_body.tres
Normal file
4
gears/geep_body.tres
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[gd_resource type="StandardMaterial3D" load_steps=0 format=3 uid="uid://dpacu3e7vsks5"]
|
||||
|
||||
[resource]
|
||||
albedo_color = Color(0.99607843, 0.99607843, 0.99607843, 1)
|
||||
4
gears/geep_wheel.tres
Normal file
4
gears/geep_wheel.tres
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[gd_resource type="StandardMaterial3D" load_steps=0 format=3 uid="uid://bt5aat64e478k"]
|
||||
|
||||
[resource]
|
||||
albedo_color = Color(0.1254902, 0.1254902, 0.1254902, 1)
|
||||
47
main.tscn
47
main.tscn
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://eiaw4xbs3suk"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cnbm3aqyg0p2o" path="res://server.gd" id="1_5vw27"]
|
||||
[ext_resource type="PackedScene" uid="uid://qb8cbljxgnub" path="res://world/killbrick.tscn" id="1_h2yge"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfceg80unq0pe" path="res://player/player.tscn" id="1_ig7tw"]
|
||||
[ext_resource type="PackedScene" uid="uid://bcmrj6qkemrll" path="res://world/radiohead_cube.tscn" id="2_0xm2m"]
|
||||
[ext_resource type="Texture2D" uid="uid://wdjmyv260he1" path="res://world/textures/grass.jpg" id="2_272bh"]
|
||||
[ext_resource type="PackedScene" uid="uid://of6tq8gpjxtu" path="res://gears/gear_pickup.tscn" id="3_lquwl"]
|
||||
|
|
@ -40,8 +40,7 @@ glow_hdr_luminance_cap = 0.0
|
|||
[sub_resource type="Compositor" id="Compositor_5vw27"]
|
||||
|
||||
[node name="Main" type="Node3D"]
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("1_ig7tw")]
|
||||
script = ExtResource("1_5vw27")
|
||||
|
||||
[node name="Baseplate" type="StaticBody3D" parent="."]
|
||||
|
||||
|
|
@ -82,3 +81,45 @@ compositor = SubResource("Compositor_5vw27")
|
|||
transform = Transform3D(0.70710665, 0.5, -0.5, 0, 0.7071067, 0.7071067, 0.7071069, -0.49999988, 0.49999988, -500, 200, 500)
|
||||
light_color = Color(1, 0.87058824, 0.12941177, 1)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="UI" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Menu" type="Panel" parent="UI"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="UI/Menu"]
|
||||
layout_mode = 0
|
||||
offset_right = 1149.0
|
||||
offset_bottom = 134.0
|
||||
theme_override_constants/margin_left = 15
|
||||
theme_override_constants/margin_top = 15
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="UI/Menu/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="UI/Menu/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Menu
|
||||
"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ServerButton2" type="Button" parent="UI/Menu/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Host
|
||||
"
|
||||
|
||||
[node name="ClientButton" type="Button" parent="UI/Menu/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Join
|
||||
"
|
||||
|
||||
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."]
|
||||
_spawnable_scenes = PackedStringArray("uid://cfceg80unq0pe")
|
||||
spawn_path = NodePath("..")
|
||||
|
||||
[connection signal="pressed" from="UI/Menu/MarginContainer/VBoxContainer/ServerButton2" to="." method="_on_server_button_pressed"]
|
||||
[connection signal="pressed" from="UI/Menu/MarginContainer/VBoxContainer/ClientButton" to="." method="_on_client_button_pressed"]
|
||||
|
|
|
|||
21
menu.tscn
Normal file
21
menu.tscn
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[gd_scene format=3 uid="uid://dbv3ty2ulxir4"]
|
||||
|
||||
[node name="Menu" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
|
||||
[node name="client_button" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_right = 200.0
|
||||
offset_bottom = 100.0
|
||||
text = "Client
|
||||
"
|
||||
|
||||
[node name="server_button" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_top = 165.0
|
||||
offset_right = 200.0
|
||||
offset_bottom = 265.0
|
||||
text = "Server
|
||||
|
||||
"
|
||||
|
|
@ -8,14 +8,21 @@ const gear_slots = ["1", "2", "3"]
|
|||
|
||||
@onready var spawn = Vector3(position)
|
||||
|
||||
var starting_gear = preload("res://gears/ball.tscn")
|
||||
var starting_gear = preload("res://gears/gear.tscn")
|
||||
|
||||
var dead = false
|
||||
var protected = false
|
||||
var suspended = false
|
||||
var direction = Vector3.ZERO
|
||||
var target_velocity = Vector3.ZERO
|
||||
|
||||
var _health = 100
|
||||
|
||||
# Multiplayer
|
||||
|
||||
func _enter_tree():
|
||||
set_multiplayer_authority(str(name).to_int())
|
||||
|
||||
# Player UI
|
||||
|
||||
func resize_ui():
|
||||
|
|
@ -45,6 +52,8 @@ func message(string):
|
|||
# State functions
|
||||
|
||||
func harm(hp):
|
||||
if protected:
|
||||
return
|
||||
assert(hp >= 0)
|
||||
_health -= hp
|
||||
make_hud()
|
||||
|
|
@ -57,7 +66,8 @@ func heal(hp):
|
|||
func health():
|
||||
return _health
|
||||
|
||||
func die():
|
||||
func _die():
|
||||
dead = true
|
||||
suspended = true
|
||||
visible = false
|
||||
$HUD.visible = false
|
||||
|
|
@ -65,17 +75,24 @@ func die():
|
|||
# strip gears
|
||||
for gear in $Backpack.get_children():
|
||||
gear.queue_free()
|
||||
$Pivot/Container/Gear.queue_free()
|
||||
if has_node("Pivot/Container/Gear"):
|
||||
$Pivot/Container/Gear.unequip(self)
|
||||
$Pivot/Container/Gear.queue_free()
|
||||
|
||||
$RespawnTimer.start()
|
||||
message("Le gone")
|
||||
|
||||
func die():
|
||||
if protected:
|
||||
return
|
||||
_die()
|
||||
|
||||
func respawn():
|
||||
position = Vector3(spawn)
|
||||
$CameraGimbal.reset()
|
||||
_health = 100
|
||||
visible = true
|
||||
suspended = false
|
||||
dead = false
|
||||
|
||||
# add starting gear
|
||||
var gear = starting_gear.instantiate()
|
||||
|
|
@ -103,6 +120,7 @@ func use_backpack_slot(n):
|
|||
# place current gear in first free slot
|
||||
var slot = find_free_slot()
|
||||
if slot:
|
||||
old.unequip(self)
|
||||
old.name = slot
|
||||
old.reparent($Backpack, false)
|
||||
get_node(gear_node).reparent($Pivot/Container, false)
|
||||
|
|
@ -111,7 +129,8 @@ func use_backpack_slot(n):
|
|||
return
|
||||
# couldn't find a free slot, so replace
|
||||
# the new slot with the current gear
|
||||
get_node(gear_node).reparent($Pivot/Container, false)
|
||||
get_node(gear_node).reparent($Pivot/Container, false)
|
||||
old.unequip(self)
|
||||
old.reparent($Backpack, false)
|
||||
old.name = n
|
||||
get_node("Pivot/Container/" + n).name = "Gear"
|
||||
|
|
@ -119,6 +138,8 @@ func use_backpack_slot(n):
|
|||
return
|
||||
|
||||
func equip(gear: Gear):
|
||||
if suspended:
|
||||
return
|
||||
var gear_name = gear.gear_name()
|
||||
# do we have the gear equipped?
|
||||
if gear_name == $Pivot/Container/Gear.gear_name():
|
||||
|
|
@ -135,6 +156,7 @@ func equip(gear: Gear):
|
|||
# place current gear in first free slot
|
||||
var slot = find_free_slot()
|
||||
if slot:
|
||||
old.unequip(self)
|
||||
old.name = slot
|
||||
old.reparent($Backpack, false)
|
||||
new_gear = gear.duplicate()
|
||||
|
|
@ -180,16 +202,17 @@ func do_movement(delta):
|
|||
var mx = 0
|
||||
var mz = 0
|
||||
|
||||
if Input.is_action_pressed("move_forward"):
|
||||
mz -= 1
|
||||
if Input.is_action_pressed("move_back"):
|
||||
mz += 1
|
||||
if Input.is_action_pressed("move_left"):
|
||||
mx -= 1
|
||||
if Input.is_action_pressed("move_right"):
|
||||
mx += 1
|
||||
if Input.is_action_pressed("jump") and is_on_floor():
|
||||
target_velocity.y = jump_power
|
||||
if not suspended:
|
||||
if Input.is_action_pressed("move_forward"):
|
||||
mz -= 1
|
||||
if Input.is_action_pressed("move_back"):
|
||||
mz += 1
|
||||
if Input.is_action_pressed("move_left"):
|
||||
mx -= 1
|
||||
if Input.is_action_pressed("move_right"):
|
||||
mx += 1
|
||||
if Input.is_action_pressed("jump") and is_on_floor():
|
||||
target_velocity.y = jump_power
|
||||
|
||||
if !(mx == 0 and mz == 0):
|
||||
move_player(mx, mz)
|
||||
|
|
@ -221,13 +244,23 @@ func _ready():
|
|||
resize_ui()
|
||||
respawn()
|
||||
|
||||
if is_multiplayer_authority():
|
||||
$CameraGimbal/InnerGimbal/Camera3D.current = true
|
||||
else:
|
||||
$CameraGimbal/InnerGimbal/Camera3D.current = false
|
||||
|
||||
func _physics_process(delta):
|
||||
if dead or not is_multiplayer_authority():
|
||||
return
|
||||
if health() < 1 or position.y <= -1000:
|
||||
die()
|
||||
|
||||
if suspended:
|
||||
return
|
||||
|
||||
if health() < 1 or position.y <= -1000:
|
||||
_die()
|
||||
|
||||
# Backpack keys
|
||||
do_backpack_keys()
|
||||
# Movement
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=8 format=4 uid="uid://cfceg80unq0pe"]
|
||||
[gd_scene load_steps=9 format=4 uid="uid://cfceg80unq0pe"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bfflnag3p4gen" path="res://player/player.gd" id="1_onrkg"]
|
||||
[ext_resource type="Script" uid="uid://oi6sint7jkc6" path="res://player/camera_gimbal.gd" id="2_onrkg"]
|
||||
|
|
@ -47,6 +47,32 @@ _surfaces = [{
|
|||
}]
|
||||
shadow_mesh = SubResource("ArrayMesh_e57bw")
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_g1dw6"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:rotation")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath("CameraGimbal:position")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 1
|
||||
properties/3/path = NodePath("CameraGimbal:rotation")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 1
|
||||
properties/4/path = NodePath("CameraGimbal/InnerGimbal:position")
|
||||
properties/4/spawn = true
|
||||
properties/4/replication_mode = 1
|
||||
properties/5/path = NodePath("CameraGimbal/InnerGimbal:rotation")
|
||||
properties/5/spawn = true
|
||||
properties/5/replication_mode = 1
|
||||
properties/6/path = NodePath("CameraGimbal/InnerGimbal/Camera3D:position")
|
||||
properties/6/spawn = true
|
||||
properties/6/replication_mode = 1
|
||||
properties/7/path = NodePath("CameraGimbal/InnerGimbal/Camera3D:rotation")
|
||||
properties/7/spawn = true
|
||||
properties/7/replication_mode = 1
|
||||
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 3
|
||||
|
|
@ -58,7 +84,9 @@ shape = SubResource("BoxShape3D_onrkg")
|
|||
|
||||
[node name="Pivot" type="Node3D" parent="."]
|
||||
|
||||
[node name="PlayerMesh" type="MeshInstance3D" parent="Pivot"]
|
||||
[node name="Mesh" type="Node3D" parent="Pivot"]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Pivot/Mesh"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, -100, 0)
|
||||
mesh = SubResource("ArrayMesh_sweqy")
|
||||
skeleton = NodePath("")
|
||||
|
|
@ -100,6 +128,9 @@ text = "Pictures of you"
|
|||
horizontal_alignment = 2
|
||||
vertical_alignment = 2
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_g1dw6")
|
||||
|
||||
[connection signal="child_entered_tree" from="Backpack" to="." method="_on_backpack_child_entered_tree"]
|
||||
[connection signal="child_exiting_tree" from="Backpack" to="." method="_on_backpack_child_exiting_tree"]
|
||||
[connection signal="timeout" from="RespawnTimer" to="." method="respawn"]
|
||||
|
|
|
|||
27
server.gd
Normal file
27
server.gd
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
extends Node3D
|
||||
|
||||
@onready var menu = $UI/Menu
|
||||
|
||||
const PORT = 9999
|
||||
const PLAYER = preload("res://player/player.tscn")
|
||||
var peer = ENetMultiplayerPeer.new()
|
||||
|
||||
|
||||
|
||||
func _on_server_button_pressed() -> void:
|
||||
menu.hide()
|
||||
peer.create_server(PORT)
|
||||
multiplayer.multiplayer_peer = peer
|
||||
multiplayer.peer_connected.connect(add_player)
|
||||
|
||||
add_player(multiplayer.get_unique_id())
|
||||
|
||||
func _on_client_button_pressed() -> void:
|
||||
menu.hide()
|
||||
peer.create_client("localhost",PORT)
|
||||
multiplayer.multiplayer_peer = peer
|
||||
|
||||
func add_player(peer_id):
|
||||
var player = PLAYER.instantiate()
|
||||
player.name = str(peer_id)
|
||||
add_child(player)
|
||||
4
util/util.gd
Normal file
4
util/util.gd
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
class_name Util extends Node
|
||||
|
||||
static func input_action_string(action):
|
||||
return InputMap.action_get_events(action)[0].as_text()
|
||||
Loading…
Add table
Add a link
Reference in a new issue