Basic movement sync. Replaced beer cans.
parent
4bc03de495
commit
651c582ce6
|
@ -83,6 +83,9 @@ func _ready() -> void:
|
|||
#Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
view_zoom = 1.0
|
||||
|
||||
rpc_config(&"move_and_slide", MultiplayerAPI.RPC_MODE_REMOTESYNC)
|
||||
rpc_config(&"set_global_transform", MultiplayerAPI.RPC_MODE_PUPPET)
|
||||
|
||||
func aim(event) -> void:
|
||||
var mouse_motion = event as InputEventMouseMotion
|
||||
|
||||
|
@ -110,6 +113,8 @@ func _input(event) -> void:
|
|||
aim(event)
|
||||
|
||||
func _physics_process(delta):
|
||||
rpc_unreliable(&'set_global_transform', global_transform)
|
||||
|
||||
direction = Vector3.ZERO
|
||||
|
||||
if is_on_floor() and ground_check.is_colliding():
|
||||
|
@ -145,7 +150,8 @@ func _physics_process(delta):
|
|||
|
||||
linear_velocity = velocity + gravity_vec
|
||||
#slide = move_and_slide_with_snap(movement, snap, Vector3.UP)
|
||||
move_and_slide()
|
||||
rpc(&"move_and_slide")
|
||||
#move_and_slide()
|
||||
|
||||
if not is_on_floor() and not ground_check.is_colliding(): # while in mid-air collisions affect momentum
|
||||
velocity.x = linear_velocity.x
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
extends Control
|
||||
|
||||
@onready var main = get_tree().get_root().get_node("Main")
|
||||
@onready var player = main.player
|
||||
@onready var player = main.local_player
|
||||
@onready var chat_history = $VBoxContainer/ChatHistory
|
||||
@onready var chat_typing = $VBoxContainer/Typing
|
||||
@onready var chat_editor = $VBoxContainer/Typing/Editor
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Props/BeerCan.glb" type="PackedScene" id=1]
|
||||
|
||||
[node name="BeerCan" instance=ExtResource( 1 )]
|
|
@ -8,6 +8,9 @@
|
|||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Menu" parent="." instance=ExtResource( 2 )]
|
||||
offset_left = 477.0
|
||||
|
|
51
Game/Main.gd
51
Game/Main.gd
|
@ -3,7 +3,7 @@ extends Node
|
|||
enum GameFocus {MENU, GAME, CHAT, AWAY}
|
||||
|
||||
const NET_PORT = 12597
|
||||
const NET_SERVER = "liblast.unfa.xyz"
|
||||
const NET_SERVER = "localhost"# "liblast.unfa.xyz"
|
||||
|
||||
var peer = NetworkedMultiplayerENet.new()
|
||||
|
||||
|
@ -11,8 +11,8 @@ var player_scene = preload("res://Assets/Characters/Player.tscn")
|
|||
|
||||
@onready var gui = $GUI
|
||||
@onready var hud = $HUD
|
||||
@onready var player = $Level/Player
|
||||
@onready var chat = hud.get_node("Chat")
|
||||
var local_player: Node = null
|
||||
|
||||
var focus = GameFocus.MENU :
|
||||
set(new_focus):
|
||||
|
@ -20,15 +20,19 @@ var focus = GameFocus.MENU :
|
|||
0:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
gui.show()
|
||||
player.input_active = false
|
||||
if local_player:
|
||||
local_player.input_active = false
|
||||
1:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
gui.hide()
|
||||
player.input_active = true
|
||||
if local_player:
|
||||
local_player.input_active = true
|
||||
2:
|
||||
player.input_active = false
|
||||
if local_player:
|
||||
local_player.input_active = false
|
||||
3:
|
||||
player.input_active = true
|
||||
if local_player:
|
||||
local_player.input_active = true
|
||||
|
||||
focus = new_focus
|
||||
|
||||
|
@ -39,28 +43,50 @@ func _input(_event) -> void:
|
|||
elif focus == GameFocus.MENU:
|
||||
focus = GameFocus.GAME
|
||||
|
||||
|
||||
func create_player(id: int, is_local) -> void:
|
||||
var new_player = player_scene.instance()
|
||||
var spawnpoint = $Map/SpawnPoints.get_children()[randi() % len($Map/SpawnPoints.get_children())]
|
||||
new_player.name = str(id)
|
||||
new_player.global_transform = spawnpoint.global_transform
|
||||
new_player.set_network_master(id)
|
||||
$Players.add_child(new_player)
|
||||
|
||||
if is_local:
|
||||
local_player = $Players.get_node(str(id))
|
||||
local_player.get_node("Head/Camera").current = true
|
||||
else:
|
||||
$Players.get_node(str(id) + "/Head/Camera").current = false
|
||||
|
||||
func _on_Host_pressed():
|
||||
$NetworkTesting/Host.disabled = true
|
||||
$NetworkTesting/Connect.disabled = true
|
||||
|
||||
peer.create_server(NET_PORT, 16)
|
||||
get_tree().network_peer = peer
|
||||
create_player(1, true)
|
||||
|
||||
func _on_Connect_pressed():
|
||||
$NetworkTesting/Host.disabled = true
|
||||
$NetworkTesting/Connect.disabled = true
|
||||
|
||||
peer.create_client(NET_SERVER, NET_PORT)
|
||||
get_tree().network_peer = peer
|
||||
|
||||
|
||||
func _player_connected(id) -> void:
|
||||
print("player connected, id: ", id)
|
||||
var new_player = player_scene.instance()
|
||||
new_player.set_network_master(id)
|
||||
var spawnpoint = $Map/SpawnPoints.get_children()[randi() % size($Map/SpawnPoints.get_children())]
|
||||
new_player.name = id
|
||||
new_player.global_transform = spawnpoint.global_transform
|
||||
$Players.add_child(new_player)
|
||||
create_player(id, false)
|
||||
|
||||
|
||||
func _player_disconnected(id) -> void:
|
||||
print("player disconnected, id: ", id)
|
||||
|
||||
|
||||
func _connected_ok() -> void:
|
||||
print("connected to server")
|
||||
var id = get_tree().get_network_unique_id()
|
||||
create_player(id, true)
|
||||
|
||||
func _connected_fail() -> void:
|
||||
print("connection to server failed")
|
||||
|
@ -68,6 +94,7 @@ func _connected_fail() -> void:
|
|||
func _server_disconnected() -> void:
|
||||
print("server disconnected")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
get_tree().connect("network_peer_connected", self._player_connected)
|
||||
get_tree().connect("network_peer_disconnected", self._player_disconnected)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Level.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Map.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://GUI.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Main.gd" type="Script" id=3]
|
||||
[ext_resource path="res://Assets/HUD/HUD.tscn" type="PackedScene" id=4]
|
||||
|
@ -16,6 +16,7 @@ script = ExtResource( 3 )
|
|||
script = null
|
||||
|
||||
[node name="Map" parent="." instance=ExtResource( 1 )]
|
||||
transform = Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1 )
|
||||
|
||||
[node name="NetworkTesting" type="VBoxContainer" parent="."]
|
||||
anchor_bottom = 1.0
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/MapComponents/SpawnPoint.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Assets/Props/BeerCan.glb" type="PackedScene" id=3]
|
||||
[ext_resource path="res://Assets/Maps/DM1/DM1.glb" type="PackedScene" id=6]
|
||||
[ext_resource path="res://Assets/Props/BeerCan.tscn" type="PackedScene" id=8]
|
||||
|
||||
[sub_resource type="PhysicalSkyMaterial" id=1]
|
||||
|
||||
|
@ -15,6 +15,7 @@ sky = SubResource( 2 )
|
|||
ambient_light_sky_contribution = 0.1
|
||||
tonemap_mode = 2
|
||||
tonemap_white = 2.0
|
||||
ssao_enabled = true
|
||||
ssao_radius = 8.0
|
||||
ssao_intensity = 1.0
|
||||
sdfgi_read_sky_light = true
|
||||
|
@ -75,15 +76,12 @@ script = null
|
|||
|
||||
[node name="ReflectionProbe" type="ReflectionProbe" parent="."]
|
||||
transform = Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 13, 0 )
|
||||
visible = false
|
||||
extents = Vector3( 33, 13, 29 )
|
||||
box_projection = true
|
||||
interior = true
|
||||
enable_shadows = true
|
||||
script = null
|
||||
|
||||
[node name="BeerCan" parent="." instance=ExtResource( 8 )]
|
||||
transform = Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 22, 11, -3 )
|
||||
|
||||
[node name="SpawnPoints" type="Node3D" parent="."]
|
||||
script = null
|
||||
__meta__ = {
|
||||
|
@ -96,4 +94,31 @@ transform = Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 10, 17 )
|
|||
[node name="SpawnPoint2" parent="SpawnPoints" instance=ExtResource( 1 )]
|
||||
transform = Transform3D( -1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 2, 17, -14 )
|
||||
|
||||
[node name="SpawnPoint3" parent="SpawnPoints" instance=ExtResource( 1 )]
|
||||
transform = Transform3D( 7.54979e-08, 0, 1, 0, 1, 0, -1, 0, 7.54979e-08, -15.6104, 4.1427, -0.166348 )
|
||||
|
||||
[node name="SpawnPoint4" parent="SpawnPoints" instance=ExtResource( 1 )]
|
||||
transform = Transform3D( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 30.0169, 4.1427, -9.16634 )
|
||||
|
||||
[node name="SpawnPoint5" parent="SpawnPoints" instance=ExtResource( 1 )]
|
||||
transform = Transform3D( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 30.0169, 4.1427, 8.83366 )
|
||||
|
||||
[node name="Camera" type="Camera3D" parent="."]
|
||||
transform = Transform3D( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -19, 12.3983, -8.74228e-08 )
|
||||
current = true
|
||||
fov = 60.0
|
||||
script = null
|
||||
|
||||
[node name="BeerCan4" parent="." instance=ExtResource( 3 )]
|
||||
transform = Transform3D( 0.5, 0.866025, 0, -0.866025, 0.5, 0, 0, 0, 1, 26.7206, 2.18397, -2 )
|
||||
|
||||
[node name="BeerCan5" parent="." instance=ExtResource( 3 )]
|
||||
transform = Transform3D( 0.5, -0.612372, -0.612372, 0.866025, 0.353553, 0.353553, 1.49012e-08, -0.707107, 0.707107, 28, 9.8, 3 )
|
||||
|
||||
[node name="BeerCan6" parent="." instance=ExtResource( 3 )]
|
||||
transform = Transform3D( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 30, 2.3, 2 )
|
||||
|
||||
[node name="BeerCan3" parent="." instance=ExtResource( 3 )]
|
||||
transform = Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 29.3, 2.6, 3.6 )
|
||||
|
||||
[editable path="DM1"]
|
|
@ -124,8 +124,13 @@ say_cancel={
|
|||
|
||||
[rendering]
|
||||
|
||||
anti_aliasing/screen_space_roughness_limiter/enabled=false
|
||||
global_illumination/sdfgi/probe_ray_count=2
|
||||
global_illumination/sdfgi/frames_to_converge=0
|
||||
global_illumination/sdfgi/frames_to_update_lights=4
|
||||
anti_aliasing/quality/msaa=1
|
||||
anti_aliasing/quality/screen_space_aa=1
|
||||
anti_aliasing/quality/use_debanding=true
|
||||
occlusion_culling/use_occlusion_culling=true
|
||||
mesh_lod/lod_change/threshold_pixels=3.0
|
||||
environment/defaults/default_environment="res://default_env.tres"
|
||||
|
|
Reference in New Issue