Multiplayer fully works
|
@ -10,16 +10,20 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
|||
@export var Bullet = preload("res://objects/Bullet/Bullet.tscn")
|
||||
@onready var neck := $CollisionShape3D/Neck
|
||||
@onready var camera := $CollisionShape3D/Neck/Camera3D
|
||||
@onready var selfTeddy = self.get_path()
|
||||
@onready var teddyParent = get_node(selfTeddy).get_parent()
|
||||
var selfTeddy
|
||||
var teddyParent
|
||||
|
||||
var globalscene
|
||||
|
||||
func _ready():
|
||||
name = str(get_multiplayer_authority())
|
||||
Global.playingGame = true
|
||||
Global.selfTeddy = selfTeddy
|
||||
selfTeddy = self.get_path()
|
||||
teddyParent = get_node(selfTeddy).get_parent()
|
||||
|
||||
func _unhandled_input(event):
|
||||
Global.selfTeddy = selfTeddy
|
||||
if event is InputEventMouseButton:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
elif event.is_action_pressed("ui_cancel"):
|
||||
|
@ -45,64 +49,82 @@ func _unhandled_input(event):
|
|||
globalscene.queue_free()
|
||||
|
||||
func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity.y -= gravity * delta
|
||||
# This variable gets set my the death scene, so we know the player needs to be respawned
|
||||
if Global.playerPleaseRespawn == true:
|
||||
position.x = 0 #Set player X
|
||||
position.y = 1 #Set player Y
|
||||
position.z = 0 #Set player Z
|
||||
Global.reset_variables()
|
||||
if is_multiplayer_authority():
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity.y -= gravity * delta
|
||||
# This variable gets set my the death scene, so we know the player needs to be respawned
|
||||
if Global.playerPleaseRespawn == true:
|
||||
position.x = 0 #Set player X
|
||||
position.y = 1 #Set player Y
|
||||
position.z = 0 #Set player Z
|
||||
Global.reset_variables()
|
||||
|
||||
## If player falls off the map, kill them!
|
||||
if velocity.y < Global.playerYDeath:
|
||||
Global.playerHealth = 0
|
||||
if Global.playerHealth <= 0:
|
||||
Global.player_dead()
|
||||
## If player falls off the map, kill them!
|
||||
if velocity.y < Global.playerYDeath:
|
||||
Global.playerHealth = 0
|
||||
if Global.playerHealth <= 0:
|
||||
Global.player_dead()
|
||||
|
||||
|
||||
if Global.playerAlive:
|
||||
# Handle Jump.
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
var input_dir = Input.get_vector("player_left", "player_right", "player_forward", "player_backward")
|
||||
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
if Input.is_action_pressed("sprint"):
|
||||
if Global.fatigue > 5:
|
||||
SPEED = 10.0
|
||||
if Global.fatigue < 5:
|
||||
SPEED = 2.0
|
||||
if Input.is_action_pressed("sprint"):
|
||||
pass
|
||||
elif Global.fatigue > 5:
|
||||
SPEED = 5.0
|
||||
if Input.is_action_just_released("sprint"):
|
||||
SPEED = 5.0
|
||||
if direction:
|
||||
velocity.x = direction.x * SPEED
|
||||
velocity.z = direction.z * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
if Global.playerDead:
|
||||
velocity.x = 0
|
||||
velocity.z = 0
|
||||
if Input.is_action_just_pressed("shoot"):
|
||||
if Global.menuOpen == false:
|
||||
print("shoot")
|
||||
var b = Bullet.instantiate()
|
||||
teddyParent.add_child(b)
|
||||
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"):
|
||||
var scene_trs = load("res://scenes/console.tscn")
|
||||
var scene = scene_trs.instantiate()
|
||||
if not Global.consoleOpen:
|
||||
Global.consoleOpen = true
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
add_child(scene)
|
||||
elif Global.consoleOpen:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
Global.consoleOpen = false # We remove the scene in console.gd
|
||||
move_and_slide()
|
||||
if Global.playerAlive:
|
||||
# Handle Jump.
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
var input_dir = Input.get_vector("player_left", "player_right", "player_forward", "player_backward")
|
||||
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
if Input.is_action_pressed("sprint"):
|
||||
if Global.fatigue > 5:
|
||||
SPEED = 10.0
|
||||
if Global.fatigue < 5:
|
||||
SPEED = 2.0
|
||||
if Input.is_action_pressed("sprint"):
|
||||
pass
|
||||
elif Global.fatigue > 5:
|
||||
SPEED = 5.0
|
||||
if Input.is_action_just_released("sprint"):
|
||||
SPEED = 5.0
|
||||
if direction:
|
||||
velocity.x = direction.x * SPEED
|
||||
velocity.z = direction.z * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
if Global.playerDead:
|
||||
velocity.x = 0
|
||||
velocity.z = 0
|
||||
if Input.is_action_just_pressed("shoot"):
|
||||
if Global.menuOpen == false:
|
||||
if Global.multiplayerCurrent == true:
|
||||
rpc("shoot_bullet", 1)
|
||||
shoot_bullet(0)
|
||||
else:
|
||||
shoot_bullet(1)
|
||||
if Input.is_action_just_pressed("console"):
|
||||
var scene_trs = load("res://scenes/console.tscn")
|
||||
var scene = scene_trs.instantiate()
|
||||
if not Global.consoleOpen:
|
||||
Global.consoleOpen = true
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
add_child(scene)
|
||||
elif Global.consoleOpen:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
Global.consoleOpen = false # We remove the scene in console.gd
|
||||
rpc("remote_set_position", global_position, $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_position, $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_rotation)
|
||||
move_and_slide()
|
||||
|
||||
@rpc("any_peer", "unreliable")
|
||||
func remote_set_position(authority_position, bulletgenerator_position, bulletgenerator_rotation):
|
||||
global_position = authority_position
|
||||
$CollisionShape3D/Neck/Camera3D/BulletGenerator.global_position = bulletgenerator_position
|
||||
$CollisionShape3D/Neck/Camera3D/BulletGenerator.global_rotation = bulletgenerator_rotation
|
||||
|
||||
@rpc("any_peer", "reliable")
|
||||
func shoot_bullet(sound):
|
||||
var b = Bullet.instantiate()
|
||||
teddyParent.add_child(b)
|
||||
b.transform = $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_transform
|
||||
b.velocity = -b.global_transform.basis.z * b.muzzle_velocity
|
||||
if sound == 1:
|
||||
$sound.stream = load("res://sounds/pistol_shoot.wav")
|
||||
$sound.play()
|
||||
|
|
BIN
objects/toyland/Wood050_2K_Color.jpg
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
objects/toyland/Wood050_2K_Color.jpg.001.jpg
Normal file
After Width: | Height: | Size: 59 KiB |
34
objects/toyland/Wood050_2K_Color.jpg.001.jpg.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bhnl0h66m0jst"
|
||||
path="res://.godot/imported/Wood050_2K_Color.jpg.001.jpg-9f5b9ace6c04569729f5d745a25bcc3f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/Wood050_2K_Color.jpg.001.jpg"
|
||||
dest_files=["res://.godot/imported/Wood050_2K_Color.jpg.001.jpg-9f5b9ace6c04569729f5d745a25bcc3f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
35
objects/toyland/Wood050_2K_Color.jpg.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dnobq0anmbln8"
|
||||
path.s3tc="res://.godot/imported/Wood050_2K_Color.jpg-e6185de0fa12ff4588e435b3845fb87e.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/Wood050_2K_Color.jpg"
|
||||
dest_files=["res://.godot/imported/Wood050_2K_Color.jpg-e6185de0fa12ff4588e435b3845fb87e.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
BIN
objects/toyland/newplaster.jpg
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
objects/toyland/newplaster.jpg.001.jpg
Normal file
After Width: | Height: | Size: 58 KiB |
34
objects/toyland/newplaster.jpg.001.jpg.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://rdm6mfwbwg6s"
|
||||
path="res://.godot/imported/newplaster.jpg.001.jpg-4d68a0e7c6211fbeba658a0e6fc2cd5f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/newplaster.jpg.001.jpg"
|
||||
dest_files=["res://.godot/imported/newplaster.jpg.001.jpg-4d68a0e7c6211fbeba658a0e6fc2cd5f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
35
objects/toyland/newplaster.jpg.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cmhq2gjngssxg"
|
||||
path.s3tc="res://.godot/imported/newplaster.jpg-c0159d01e1a6adffe0c3bf5b8dcfc7a7.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/newplaster.jpg"
|
||||
dest_files=["res://.godot/imported/newplaster.jpg-c0159d01e1a6adffe0c3bf5b8dcfc7a7.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
After Width: | Height: | Size: 407 KiB |
|
@ -0,0 +1,36 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c4brgjvonnjkr"
|
||||
path.s3tc="res://.godot/imported/toyland-acc3ec7302587eef6111479be4ff2e5f_Wood050_2K_Color.png-09e60c6431251b5cdad5e7603ca8ef91.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
generator_parameters={}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/toyland-acc3ec7302587eef6111479be4ff2e5f_Wood050_2K_Color.png"
|
||||
dest_files=["res://.godot/imported/toyland-acc3ec7302587eef6111479be4ff2e5f_Wood050_2K_Color.png-09e60c6431251b5cdad5e7603ca8ef91.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
After Width: | Height: | Size: 478 KiB |
|
@ -0,0 +1,36 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ql40b60xucke"
|
||||
path.s3tc="res://.godot/imported/toyland-acc3ec7302587eef6111479be4ff2e5f_newplaster.png-56bf5185a878e2d32e5a25ec8c8517fb.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
generator_parameters={}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/toyland-acc3ec7302587eef6111479be4ff2e5f_newplaster.png"
|
||||
dest_files=["res://.godot/imported/toyland-acc3ec7302587eef6111479be4ff2e5f_newplaster.png-56bf5185a878e2d32e5a25ec8c8517fb.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
After Width: | Height: | Size: 773 KiB |
|
@ -0,0 +1,36 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cj28kq4i36gcg"
|
||||
path.s3tc="res://.godot/imported/toyland-acc3ec7302587eef6111479be4ff2e5f_windows_xp_bliss-wide.png-c0ea880c9d43e5d1d8d800dd069f83dd.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
generator_parameters={}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/toyland-acc3ec7302587eef6111479be4ff2e5f_windows_xp_bliss-wide.png"
|
||||
dest_files=["res://.godot/imported/toyland-acc3ec7302587eef6111479be4ff2e5f_windows_xp_bliss-wide.png-c0ea880c9d43e5d1d8d800dd069f83dd.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
2902
objects/toyland/toylandnocolliders.dae
Normal file
32
objects/toyland/toylandnocolliders.dae.import
Normal file
|
@ -0,0 +1,32 @@
|
|||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://c3gou5ubatac0"
|
||||
path="res://.godot/imported/toylandnocolliders.dae-8a4ebb92a340a4c00fd2c8b7efc1aae4.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/toylandnocolliders.dae"
|
||||
dest_files=["res://.godot/imported/toylandnocolliders.dae-8a4ebb92a340a4c00fd2c8b7efc1aae4.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type="Node3D"
|
||||
nodes/root_name="Scene Root"
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/embedded_image_handling=1
|
BIN
objects/toyland/windows_xp_bliss-wide.jpg
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
objects/toyland/windows_xp_bliss-wide.jpg.001.jpg
Normal file
After Width: | Height: | Size: 90 KiB |
34
objects/toyland/windows_xp_bliss-wide.jpg.001.jpg.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://diruf5vyv41pv"
|
||||
path="res://.godot/imported/windows_xp_bliss-wide.jpg.001.jpg-1ed28ba1c5c304ae15d500fa2d1079b2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/windows_xp_bliss-wide.jpg.001.jpg"
|
||||
dest_files=["res://.godot/imported/windows_xp_bliss-wide.jpg.001.jpg-1ed28ba1c5c304ae15d500fa2d1079b2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
35
objects/toyland/windows_xp_bliss-wide.jpg.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://co6sxyhce6s7"
|
||||
path.s3tc="res://.godot/imported/windows_xp_bliss-wide.jpg-b027b98d80d6be8ceaca628f4dcf54ce.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/windows_xp_bliss-wide.jpg"
|
||||
dest_files=["res://.godot/imported/windows_xp_bliss-wide.jpg-b027b98d80d6be8ceaca628f4dcf54ce.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
BIN
objects/toyland/woodfloor4k.jpg.001.jpg
Normal file
After Width: | Height: | Size: 52 KiB |
35
objects/toyland/woodfloor4k.jpg.001.jpg.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b6f2baaxv23qx"
|
||||
path.s3tc="res://.godot/imported/woodfloor4k.jpg.001.jpg-e2bdf4950350ecebed41e5db675a15f9.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/woodfloor4k.jpg.001.jpg"
|
||||
dest_files=["res://.godot/imported/woodfloor4k.jpg.001.jpg-e2bdf4950350ecebed41e5db675a15f9.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
BIN
objects/toyland/woodfloor4k.jpg.002.jpg
Normal file
After Width: | Height: | Size: 52 KiB |
34
objects/toyland/woodfloor4k.jpg.002.jpg.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c0vfrlgxpq8u3"
|
||||
path="res://.godot/imported/woodfloor4k.jpg.002.jpg-e9a77dc5f9ec4b59da6d965ef9e2746d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://objects/toyland/woodfloor4k.jpg.002.jpg"
|
||||
dest_files=["res://.godot/imported/woodfloor4k.jpg.002.jpg-e9a77dc5f9ec4b59da6d965ef9e2746d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
|
@ -24,7 +24,6 @@ Networking="*res://scripts/networking.gd"
|
|||
|
||||
[display]
|
||||
|
||||
window/size/mode=3
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
[input]
|
||||
|
@ -67,6 +66,7 @@ shoot={
|
|||
console={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":96,"key_label":0,"unicode":96,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":167,"key_label":0,"unicode":96,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
console_send={
|
||||
|
|
|
@ -22,3 +22,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.104801, -0.858231)
|
|||
[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D"]
|
||||
mesh = SubResource("CapsuleMesh_ucocb")
|
||||
skeleton = NodePath("")
|
||||
|
||||
[node name="sound" type="AudioStreamPlayer3D" parent="."]
|
||||
|
|
|
@ -24,3 +24,5 @@ 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="sound" type="AudioStreamPlayer3D" parent="."]
|
||||
|
|
|
@ -69,7 +69,7 @@ offset_left = 646.0
|
|||
offset_top = 248.0
|
||||
offset_right = 797.0
|
||||
offset_bottom = 283.0
|
||||
text = "Playground"
|
||||
text = "Toyland"
|
||||
|
||||
[node name="portBox" type="LineEdit" parent="."]
|
||||
layout_mode = 0
|
||||
|
|
|
@ -8,12 +8,12 @@ sky_top_color = Color(0.870588, 0.894118, 0.92549, 1)
|
|||
sky_horizon_color = Color(0.767647, 0.765779, 0.764623, 1)
|
||||
ground_horizon_color = Color(0.767647, 0.765779, 0.764623, 1)
|
||||
|
||||
[sub_resource type="Sky" id="Sky_08e8u"]
|
||||
[sub_resource type="Sky" id="Sky_lh0lw"]
|
||||
sky_material = SubResource("ProceduralSkyMaterial_ell6n")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_fnphj"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_08e8u")
|
||||
sky = SubResource("Sky_lh0lw")
|
||||
tonemap_mode = 2
|
||||
glow_enabled = true
|
||||
|
||||
|
|
13
scenes/toyland-map.tscn
Normal file
17
scenes/toyland.tscn
Normal file
|
@ -0,0 +1,17 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bsdst5m5kpw0j"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/maps/toyland.gd" id="1_vq5un"]
|
||||
[ext_resource type="PackedScene" uid="uid://ytbacsuahxie" path="res://scenes/HUD.tscn" id="1_w2y7j"]
|
||||
[ext_resource type="PackedScene" uid="uid://borjtj4hucqw7" path="res://scenes/toyland-map.tscn" id="3_uudje"]
|
||||
|
||||
[node name="toyland" type="Node3D"]
|
||||
script = ExtResource("1_vq5un")
|
||||
|
||||
[node name="HUD" parent="." instance=ExtResource("1_w2y7j")]
|
||||
show_behind_parent = true
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(-0.0034906, -0.94887, 0.315647, 0, 0.315649, 0.948876, -0.999994, 0.00331215, -0.00110181, 0, 0, 0)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="toylandnocolliders" parent="." instance=ExtResource("3_uudje")]
|
|
@ -28,6 +28,8 @@ func _physics_process(delta):
|
|||
owner.add_child(b)
|
||||
b.transform = $CollisionShape3D/Neck/BulletGenerator.global_transform
|
||||
b.velocity = -b.global_transform.basis.z * b.muzzle_velocity
|
||||
$sound.stream = load("res://sounds/pistol_shoot.wav")
|
||||
$sound.play()
|
||||
elif bulletshot == true:
|
||||
bulletshot = false
|
||||
bulletrandom = randf_range(1.0, 50.0)
|
||||
|
|
|
@ -17,7 +17,8 @@ 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
|
||||
var multiplayerCurrent = false # Whether the player is using multiplayer
|
||||
var currentMapNode # Defined in map scripts
|
||||
|
||||
func _process(delta):
|
||||
if godMode:
|
||||
|
@ -49,7 +50,3 @@ func reset_variables():
|
|||
playerAlive = true
|
||||
playerPleaseRespawn = false
|
||||
|
||||
func add_player_character(mapNode):
|
||||
var player_character = preload("res://scenes/Teddy.tscn").instantiate()
|
||||
mapNode.add_child(player_character)
|
||||
player_character.position.y = 1
|
||||
|
|
|
@ -15,8 +15,8 @@ func _on_close_pressed():
|
|||
|
||||
|
||||
func _on_playground_pressed():
|
||||
$mapSelected.text = "Playground"
|
||||
SCENE = "res://scenes/playground.tscn"
|
||||
$mapSelected.text = "Toyland"
|
||||
SCENE = "res://scenes/toyland.tscn"
|
||||
|
||||
|
||||
func _on_start_button_pressed():
|
||||
|
@ -37,6 +37,7 @@ func _on_start_button_pressed():
|
|||
print("Player chose player limit: ", intMAX)
|
||||
Networking.create_server(intPORT, intMAX)
|
||||
Networking.load_map(SCENE)
|
||||
Networking.add_player_node(1)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
else:
|
||||
$mapSelected.text = "NO MAX PLAYERS SELECTED"
|
||||
|
|
|
@ -3,10 +3,9 @@ extends Node
|
|||
@onready var mapNode = get_node("/root/Playground")
|
||||
|
||||
func _ready():
|
||||
Global.currentMapNode = mapNode
|
||||
Global.playerHealth = 100
|
||||
Global.fatigue = 100
|
||||
if Global.multiplayerCurrent == true:
|
||||
Global.add_player_character(mapNode)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
|
|
13
scripts/maps/toyland.gd
Normal file
|
@ -0,0 +1,13 @@
|
|||
extends Node
|
||||
|
||||
@onready var mapNode = get_node("/root/toyland")
|
||||
|
||||
func _ready():
|
||||
Global.currentMapNode = mapNode
|
||||
Global.playerHealth = 100
|
||||
Global.fatigue = 100
|
||||
Global.playerYDeath = -100
|
||||
|
||||
|
||||
func _process(delta):
|
||||
pass
|
|
@ -1,7 +1,7 @@
|
|||
extends Node
|
||||
|
||||
var peer = ENetMultiplayerPeer.new()
|
||||
var SCENE = "res://scenes/playground.tscn"
|
||||
var SCENE = "res://scenes/toyland.tscn"
|
||||
|
||||
func _ready():
|
||||
$playerNameBox.text = Global.playerName
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
extends Node
|
||||
|
||||
var peer = ENetMultiplayerPeer.new()
|
||||
var SCENE = "res://scenes/playground.tscn"
|
||||
var SCENE = "res://scenes/toyland.tscn"
|
||||
var connected_peers = []
|
||||
|
||||
func create_server(port, maxPlayers):
|
||||
|
@ -20,8 +20,9 @@ func create_server(port, maxPlayers):
|
|||
func(new_peer_id):
|
||||
print("NEW CONNECTION FROM ", new_peer_id)
|
||||
await get_tree().create_timer(0.5).timeout ## REQUIRED, THE RPC IS MADE BEFORE THE CLIENT IS FULLY CONNECTED
|
||||
connected_peers.append(new_peer_id)
|
||||
rpc_id(new_peer_id, "add_newly_connected_player_character")
|
||||
rpc("add_newly_connected_player_character", new_peer_id)
|
||||
rpc_id(new_peer_id, "add_previously_connected_player_characters", connected_peers)
|
||||
add_player_node(new_peer_id)
|
||||
)
|
||||
|
||||
func load_map(map):
|
||||
|
@ -29,7 +30,24 @@ func load_map(map):
|
|||
get_tree().change_scene_to_file(map)
|
||||
|
||||
@rpc("any_peer", "call_remote")
|
||||
func add_newly_connected_player_character():
|
||||
func add_newly_connected_player_character(new_peer_id):
|
||||
print("Connected to server!")
|
||||
load_map(SCENE)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
add_player_node(new_peer_id)
|
||||
|
||||
|
||||
func add_player_node(peer_id):
|
||||
connected_peers.append(peer_id)
|
||||
var player_character = preload("res://scenes/Teddy.tscn").instantiate()
|
||||
player_character.set_multiplayer_authority(peer_id)
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
Global.currentMapNode.add_child(player_character)
|
||||
player_character.position.y = 10
|
||||
|
||||
@rpc
|
||||
func add_previously_connected_player_characters(peer_ids):
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
for peer_id in peer_ids:
|
||||
add_player_node(peer_id)
|
||||
|
||||
|
|
BIN
sounds/pistol_reload.wav
Normal file
24
sounds/pistol_reload.wav.import
Normal file
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://cn82krq4rp7wf"
|
||||
path="res://.godot/imported/pistol_reload.wav-2f9958349b7fe2240d05494dce99f911.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/pistol_reload.wav"
|
||||
dest_files=["res://.godot/imported/pistol_reload.wav-2f9958349b7fe2240d05494dce99f911.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
BIN
sounds/pistol_shoot.wav
Normal file
24
sounds/pistol_shoot.wav.import
Normal file
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bt2g2j7d74cyv"
|
||||
path="res://.godot/imported/pistol_shoot.wav-0a904657f8ee886da7af21840d2b5128.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/pistol_shoot.wav"
|
||||
dest_files=["res://.godot/imported/pistol_shoot.wav-0a904657f8ee886da7af21840d2b5128.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|