diff --git a/characters/teddy/Teddy.gd b/characters/teddy/Teddy.gd index 1e8e27a..7ea1bd7 100644 --- a/characters/teddy/Teddy.gd +++ b/characters/teddy/Teddy.gd @@ -11,12 +11,14 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") @onready var neck := $CollisionShape3D/Neck @onready var camera := $CollisionShape3D/Neck/Camera3D @onready var selfTeddy = self.get_path() +var teddyNode var globalscene func _ready(): Global.playingGame = true Global.selfTeddy = selfTeddy + teddyNode = get_node(selfTeddy) func _unhandled_input(event): if event is InputEventMouseButton: @@ -91,7 +93,7 @@ func _physics_process(delta): if Global.menuOpen == false: print("shoot") var b = Bullet.instantiate() - owner.add_child(b) + teddyNode.add_child(b) ### DO RESEARCH ON WHAT OWNER IS DEFINED AS, I FORGOT WHAT IT IS. FOR NOW IT WILL BE REPLACED WITH teddyNode BUT BULLETS ARE WACK THIS WAY b.transform = $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_transform b.velocity = -b.global_transform.basis.z * b.muzzle_velocity if Input.is_action_just_pressed("console"): diff --git a/export_presets.cfg b/export_presets.cfg index ce24fba..629ccb6 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -88,6 +88,9 @@ privacy/network_volumes_usage_description="" privacy/network_volumes_usage_description_localized={} privacy/removable_volumes_usage_description="" privacy/removable_volumes_usage_description_localized={} +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false ssh_remote_deploy/enabled=false ssh_remote_deploy/host="user@host_ip" ssh_remote_deploy/port="22" @@ -99,3 +102,45 @@ open \"{temp_dir}/{exe_name}.app\" --args {cmd_args}" ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash kill $(pgrep -x -f \"{temp_dir}/{exe_name}.app/Contents/MacOS/{exe_name} {cmd_args}\") rm -rf \"{temp_dir}\"" + +[preset.1] + +name="Linux/X11" +platform="Linux/X11" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="export/teddy.x86_64" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false +script_encryption_key="" + +[preset.1.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_script=1 +binary_format/embed_pck=false +texture_format/bptc=false +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +texture_format/no_bptc_fallbacks=true +binary_format/architecture="x86_64" +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +export DISPLAY=:0 +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +\"{temp_dir}/{exe_name}\" {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" diff --git a/objects/Bullet/Bullet.tscn b/objects/Bullet/Bullet.tscn index 9634629..b6ee2e4 100644 --- a/objects/Bullet/Bullet.tscn +++ b/objects/Bullet/Bullet.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://objects/Bullet/Bullet.gd" id="1"] [ext_resource type="PackedScene" uid="uid://pni78bumc5f5" path="res://objects/Bullet/model/Bullet.dae" id="2"] -[sub_resource type="BoxShape3D" id="BoxShape3D_h2x0g"] +[sub_resource type="BoxShape3D" id="BoxShape3D_jya8v"] size = Vector3(0.40456, 0.406836, 0.393048) [node name="Bullet" type="Area3D" groups=["bullet"]] @@ -12,7 +12,7 @@ script = ExtResource("1") [node name="CollisionShape3D" type="CollisionShape3D" parent="." groups=["bullet"]] transform = Transform3D(0.957696, 0, 0, 0, 1, 0, 0, 0, 1.66763, 0, 0, -0.295843) -shape = SubResource("BoxShape3D_h2x0g") +shape = SubResource("BoxShape3D_jya8v") [node name="Bullet" parent="." instance=ExtResource("2")] transform = Transform3D(0.200224, 0, 0, 0, -8.75207e-09, 0.200224, 0, -0.200224, -8.75207e-09, 0, 0, 0) diff --git a/scenes/Teddy.tscn b/scenes/Teddy.tscn index 04cbf6e..f71de71 100644 --- a/scenes/Teddy.tscn +++ b/scenes/Teddy.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://dp1q51kvd8uow"] +[gd_scene load_steps=4 format=3 uid="uid://dp1q51kvd8uow"] [ext_resource type="Script" path="res://characters/teddy/Teddy.gd" id="1_ywxo5"] @@ -7,14 +7,6 @@ size = Vector3(1, 1.99126, 1) [sub_resource type="CapsuleMesh" id="CapsuleMesh_qq44a"] -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_6xwyk"] -properties/0/path = NodePath(".:position") -properties/0/spawn = true -properties/0/sync = true -properties/1/path = NodePath(".:rotation") -properties/1/spawn = true -properties/1/sync = true - [node name="Teddy" type="CharacterBody3D" groups=["human"]] script = ExtResource("1_ywxo5") @@ -32,6 +24,3 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.859224, 0) [node name="BulletGenerator" type="Marker3D" parent="CollisionShape3D/Neck/Camera3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.104801, -0.858231) - -[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] -replication_config = SubResource("SceneReplicationConfig_6xwyk") diff --git a/scenes/playground.tscn b/scenes/playground.tscn index 4dc474a..ef0bca1 100644 --- a/scenes/playground.tscn +++ b/scenes/playground.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=9 format=3 uid="uid://bpq4yjx2gs3l6"] +[gd_scene load_steps=8 format=3 uid="uid://bpq4yjx2gs3l6"] [ext_resource type="Script" path="res://scripts/maps/playground.gd" id="1_gtai1"] -[ext_resource type="PackedScene" uid="uid://dp1q51kvd8uow" path="res://scenes/Teddy.tscn" id="1_p7gbl"] [ext_resource type="PackedScene" uid="uid://ytbacsuahxie" path="res://scenes/HUD.tscn" id="2_ggrqc"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_ell6n"] @@ -44,6 +43,3 @@ mesh = SubResource("PlaneMesh_gx0jf") [node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_qgsp1") - -[node name="Teddy" parent="." instance=ExtResource("1_p7gbl")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.08165e-12, 1, 2.08165e-12) diff --git a/scripts/global.gd b/scripts/global.gd index 61dc43f..35f64a2 100644 --- a/scripts/global.gd +++ b/scripts/global.gd @@ -16,6 +16,7 @@ var consoleCommand # Defined by console.gd var consoleOutput # Defined by console.gd var godMode = false # Defined by console.gd var selfTeddy # Defined as soon as the player script is initalized +var multiplayerCurrent = false func _process(delta): if godMode: @@ -46,3 +47,7 @@ func reset_variables(): playerDead = false playerAlive = true playerPleaseRespawn = false + +func add_player_character(mapNode): + var player_character = preload("res://scenes/Teddy.tscn").instantiate() + mapNode.add_child(player_character) diff --git a/scripts/host.gd b/scripts/host.gd index bb1a600..0865704 100644 --- a/scripts/host.gd +++ b/scripts/host.gd @@ -1,13 +1,7 @@ extends Node var SCENE -var peer:= ENetMultiplayerPeer.new() - -func peer_connected(pid: int): - print("Peer connected: ", pid) - -func peer_disconnected(pid: int): - print("Peer disconnected: ", pid) +var peer = ENetMultiplayerPeer.new() func _ready(): pass @@ -52,7 +46,7 @@ func _on_start_button_pressed(): func load_map(map, port, maxPlayers): var result = peer.create_server(port, maxPlayers) # Second paramater specifies the player limit. Can be anything between 1 and 4095 - peer.get_incoming_connections() + multiplayer.multiplayer_peer = peer prints("Creating server result:", result) if result == OK: print("Server should be listening on port: ", port) @@ -60,4 +54,21 @@ func load_map(map, port, maxPlayers): printerr("Port is being used by something else!") else: printerr("Server can't start, and idk the problem") - get_tree().change_scene_to_file(map) + + #Global.multiplayerCurrent = true + #get_tree().change_scene_to_file(map) + + peer.peer_connected.connect( + func(new_peer_id): + print("NEW CONNECTION FROM ", new_peer_id) + #await get_tree().create_timer(1).timeout ## Might not be required anymore... + add_newly_connected_player_character() + ) + +@rpc +func add_newly_connected_player_character(): + print("add_newly_connected_player_character() has been run!") + get_tree().change_scene_to_file("res://scenes/Playground.tscn") + + + diff --git a/scripts/maps/playground.gd b/scripts/maps/playground.gd index cadb72b..e0896dc 100644 --- a/scripts/maps/playground.gd +++ b/scripts/maps/playground.gd @@ -1,9 +1,12 @@ extends Node +@onready var mapNode = get_node("/root/Playground") func _ready(): Global.playerHealth = 100 Global.fatigue = 100 + if Global.multiplayerCurrent == true: + Global.add_player_character(mapNode) func _process(delta): diff --git a/scripts/multiplayer.gd b/scripts/multiplayer.gd index 665eaeb..81cbcb7 100644 --- a/scripts/multiplayer.gd +++ b/scripts/multiplayer.gd @@ -1,13 +1,6 @@ extends Node -var peer:= ENetMultiplayerPeer.new() - -func _on_peer_connected(id: int): - print("Peer connected: ", id) - # add your code here to handle the successful connection - -func _on_peer_disconnected(id: int): - print("Peer disconnected: ", id) +var peer = ENetMultiplayerPeer.new() func _ready(): pass @@ -42,8 +35,6 @@ func _on_join_button_pressed(): else: $errorLabel.text = "ERROR: NO PORT SPECIFIED" return - peer.connect(&"peer_connected", _on_peer_connected) - peer.connect(&"peer_disconnected", _on_peer_disconnected) var result = peer.create_client(IPADD, intPORT) var resultString = str(result) $errorLabel.text = resultString @@ -54,5 +45,8 @@ func _on_join_button_pressed(): if result == OK: print("Connected to server at IP ", IPADD, ":", intPORT, "!") $errorLabel.text = "Connected to server!" + multiplayer.multiplayer_peer = peer + Global.multiplayerCurrent = true + diff --git a/splashes/blender.svg.import b/splashes/blender.svg.import index 9c995dc..98da71f 100644 --- a/splashes/blender.svg.import +++ b/splashes/blender.svg.import @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/blender.svg-30745d3fde109c2dd09fe06f35ced49b. [params] compress/mode=0 -compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 +compress/bptc_ldr=0 compress/normal_map=0 compress/channel_pack=0 mipmaps/generate=false diff --git a/splashes/godot.svg.import b/splashes/godot.svg.import index 481fcf4..193b248 100644 --- a/splashes/godot.svg.import +++ b/splashes/godot.svg.import @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/godot.svg-dfd0c6d0b550de1675c2ab4f6216d77f.ct [params] compress/mode=0 -compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 +compress/bptc_ldr=0 compress/normal_map=0 compress/channel_pack=0 mipmaps/generate=false