#Camera system bug

1 messages · Page 1 of 1 (latest)

lilac cedar
#

If mouse entered only fires when the mouse enters, then i would assume it would only flip the value when you enter. Maybe you want to flip to true when entered and flipped to false when exited, then you might want to do something like..

var camera_flipped := false

func _on_mouse_entered() -> void:
    camera_flipped = false
    $"../TextureRect2".visible = camera_flipped

func _on_mouse_exited() -> void:
    camera_flipped = false
    $"../TextureRect2".visible = camera_flipped

Doing it this way will also protect you if mouse_entered fires multiple times

#

It's also always a good idea to throw a print() in there if you are unsure what is happening.. like this for example:

var camera_flipped := false

func _on_mouse_entered() -> void:
    print("mouse entered")
    camera_flipped = false
    $"../TextureRect2".visible = camera_flipped

func _on_mouse_exited() -> void:
    print("mouse exited")
    camera_flipped = false
    $"../TextureRect2".visible = camera_flipped
light sequoia
lilac cedar
#

office?

light sequoia
#

ye im making a fnaf game i want the camera to appear aka texturerect2 when the camera is not up if the camera is up then teturerect2 will not appear

lilac cedar
#

This problem is too abstract for me to understand. Can you simplify what you are trying to achieve?

light sequoia
#

well basically i want to hover over a collisionshape2d i created and if the camera_flipped is = true then i want to make the camera dissapear and set the camera_flipped back to false, if camera_flipped is false then make the camera appear and set the camera_flipped to true, but the problem is everytime i hover over the collisionshape2d it will always have a frame of the camera then go back to its original state

lilac cedar
#

i just tested if mouse_entered fires multiple times, and it doesn't. so your code should just flip between true and false every time you enter the collision shape

light sequoia
#

idk it doesnt work for some reason

lilac cedar
#

you could even do this..

var camera_flipped := false

func _on_mouse_entered() -> void:
    camera_flipped = not camera_flipped
    $"../TextureRect2".visible = camera_flipped
#

this would do what your original code does

light sequoia
lilac cedar
#

can you show your scene tree?

light sequoia
#

Sry

lilac cedar
#

np

light sequoia