![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | SnapCracklins |
Tried to find another thread on this but this is making me pull my hair out.
I have two variables, one that prevents player movement and one that prevent the pause HUD from being accessible (during cutscenes and reading sections). I have some events I instance frequently and they have mostly all been working until I put them into a specific scene. What is even more frustrating is that I built a one-off event in the exact same scene using the exact same methods to flip the variable and… it works. All other instances of this code also work in other scenes.
I should note - this event is tied to an area2d with collision shape - once the player enters, the input can be triggered. Don’t know if this may have something to do with it.
I have tried everything. The bools just are not cooperating. Is there something technical I am missing?
extends Area2D
### toggle event and image view
var _can_display = false
var _is_viewing = false
export var _viewNoise = false
export var _isHidden = false
func _ready(): ### hide prompt at ready
$LookSprite.visible = false
func _process(_delta):
_toggle_display() ## listen for input and bool
$LookSprite.visible = _can_display ## if can use, prompt on
if _isHidden: ## hide prompts if hidden
$LookSprite.visible = false
$RunSprite.visible = false
func _toggle_display(): ## toggling image on with flag/input
if _can_display == true:
if Input.is_action_just_pressed("_interact"):
if _is_viewing == true:
_close_view()
else:
_image_view()
if _viewNoise:
$ViewSounds.play()
func _image_view(): ## toggle view mode, pause player
_is_viewing = true
DirectorNode._pauseEnabled = false ## disable pause menu!
DirectorNode._freezePlayer = true ## disable movement
$DisplayImage.visible = true
func _close_view(): ## toggle off, player free to move
_is_viewing = false
DirectorNode._pauseEnabled = true
DirectorNode._freezePlayer = false
$DisplayImage.visible = false
func _on_ViewEvent_body_entered(body): ## toggle prompt on player enter
if body.name == 'Lydia':
if DirectorNode._chaseMode == false:
_can_display = true
else: ## show RUN if pursued
_can_display = false
$RunSprite.visible = true
$LookSprite.visible = false
func _on_ViewEvent_body_exited(body): ## hide prompt, bool flip on exit
if body.name == 'Lydia':
_can_display = false
$LookSprite.visible = false
$RunSprite.visible = false
I think its more likely that you have conflicting code, so when this code flips the variable to false/true then something else is telling it to do the exact opposite.
Gluon | 2023-02-26 10:08
I think it might have been conflicting inputs or perhaps overlapping events? I was just wondering if there was something dumb in my code I was missing (kind of Murphy’s Law in a way). Either way I ended up rebuilding my event structure entirely as separate scenes and now the conflicts are gone. Thank you for your help.
SnapCracklins | 2023-02-26 15:52
Ahh painful but at least it worked!
Gluon | 2023-02-26 16:03