Menu logic updated

This commit is contained in:
Paul Black 2023-03-18 22:08:51 -06:00
parent f35ad3c61e
commit 62491e8cd8
2 changed files with 12 additions and 19 deletions

View file

@ -17,12 +17,12 @@ var teddyCollider
var teddyName # Player name label
var teddyParent
var menuOpen = false
var globalscene
var ranRemovePlayer = false
var mousesense = Global.mouseSensitivity
var controllerAxisValue_x = 0
var controllerAxisValue_y = 0
var runnerDead = false
var menuScene
func _ready():
name = str(teddyAuthority)
@ -38,6 +38,10 @@ func _ready():
Global.teddyAuthorityID = teddyAuthority
if is_multiplayer_authority():
$CollisionShape3D/Neck/Teddy.visible = false
var scene_trs = load("res://scenes/mainmenu.tscn")
menuScene = scene_trs.instantiate()
add_child(menuScene)
menuScene.visible = false
func _unhandled_input(event):
if is_multiplayer_authority():
@ -61,24 +65,13 @@ func _unhandled_input(event):
# Clamps the camera
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-50), deg_to_rad(60))
if menuOpen == false:
if Input.is_action_just_pressed("menu"):
menuOpen = true
if Input.is_action_just_pressed("menu"):
if menuScene.visible == false:
menuScene.visible = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
var scene_trs = load("res://scenes/mainmenu.tscn")
var scene = scene_trs.instantiate()
globalscene = scene
add_child(scene)
elif menuOpen == true:
if Global.miniMenuResume == true:
menuOpen = false
Global.miniMenuResume = false
elif Global.miniMenuResume == false:
if Input.is_action_just_pressed("menu"):
menuOpen = false
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if globalscene:
globalscene.queue_free()
elif menuScene.visible == true:
menuScene.visible = false
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _physics_process(delta):
if is_multiplayer_authority():

View file

@ -35,7 +35,7 @@ func _on_button_pressed():
Global.mapName = "Tutorial"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
elif Global.playingGame == true:
self.queue_free()
self.visible = false
Global.miniMenuResume = true
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)