Stopping image from displaying after interaction

Godot Version

4.3.stable

Question

I’m having trouble getting this image to stop displaying on screen after I press the interaction key.

Code for the page I want to display:
image

When I try something like:
image
…this doesnt seem to work at all and the “.hide” function appears to not work at all. it’s really annoying. I have no idea whats going on here.

I could either have the close key - F - try and hide the image when it is displayed or try to have the Raycast hide the image when it is not colliding with the object.

Code for the interactable script:
image

Code for the interact ray which allows the interaction to happen:
image

any help…? I’m generally quite new to coding and just followed tutorials to get to this point.

Make sure to paste scripts instead of screen shots, very on-brand for your profile picture (love it btw)


func _on_interacted(_body) -> void:
    $AudioStreamPlayer3D.play()
    $pagedisplay.show()
    
    # This doesn't wait for inputs, it check if "jump" is pressed *right now*
    # only on the same frame the page is shown.
    if Input.is_action_just_pressed("jump"):
        $pagdisplay.hide()

I would make your interactable handle inputs through a _unhandled_input function, then disable it when the page isn’t shown

func _ready() -> void:
    set_process_unhandled_input(false)

func _on_interacted(_body) -> void:
    $AudioStreamPlayer3D.play()
    $pagedisplay.show()
    set_process_unhandled_input(true)

func _unhandled_input(event: InputEvent) -> void:
    if event.is_action_pressed("jump"):
        set_process_unhandled_input(false)
        $pagedisplay.hide()

thanks, i’ll try this later.

sorry for just using images i didnt really know how to format correctly so I just went with this option.

I also realized “jump” should be set to “close” in my post… I really need to pay attention ugh x_x its all good tho

update: it worked!! thank you

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.