Yeah neither of those things worked either :/
Unfortunately, I do need cameraLimitsActive to be an export variable so I can easily change it from the Inspector in the editor. Just making it an onready var would get rid of all functionality here. I tried:
export(bool) onready var cameraLimitsActive = true
which ran the game but for some reason the "onready" part kept the physical, in-game limits from being turned off. Setting it equal to $Limits.visible returned "Invalid get index 'visible' (on base: 'null instance')."
I tried the tool thing too, like this:
# Extensions
tool
extends Camera2D
# Variables
export(bool) var cameraLimitsActive = true
onready var limits = $Limits
onready var topLeftLimit = $Limits/TopLeftLimit
onready var bottomRightLimit = $Limits/BottomRightLimit
# Functions
func _ready():
if Engine.editor_hint:
if cameraLimitsActive
limits.visible = true
else:
limits.visible = false
if not Engine.editor_hint:
if cameraLimitsActive:
limit_top = topLeftLimit.position.y
limit_left = topLeftLimit.position.x
limit_bottom = bottomRightLimit.position.y
limit_right = bottomRightLimit.position.x
else:
remove_child(limits)
where again, having cameraLimitsActive equal to $Limits.visible returned "Invalid get index 'visible' (on base: 'null instance')." I tried this as a process(delta): function as well, no difference.
I got rid of the tool functionality via ctrl+Z and brought my code back to:
# Extensions
extends Camera2D
# Variables
export(bool) var cameraLimitsActive = true
onready var limits = $Limits
onready var topLeftLimit = $Limits/TopLeftLimit
onready var bottomRightLimit = $Limits/BottomRightLimit
# Functions
func _ready():
if cameraLimitsActive:
limits.visible = true
limit_top = topLeftLimit.position.y
limit_left = topLeftLimit.position.x
limit_bottom = bottomRightLimit.position.y
limit_right = bottomRightLimit.position.x
else:
remove_child(limits)
limits.visible = false
just to get us back on the same page.
At first, this Tool thing destroyed my Camera2D in my World (yes, even after removing it from my code), but I fixed that by deleting the Camera2D and adding a new one, then reassigning it to my RemoteTransform2D that connects it to my character (but that's a whole different convo).