![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Goodman599 |
Im sorry if I have already asked this question already because I cannot find any record of doing so.
I have a singleton that contains my global variables, but I have confirmed that this error remains even when it isn’t one. In it, I want to detect a change in the array “overlapping_tasks” by making a copy of it and testing for when they are different. The overlapping_tasks.append(0)
is just for demonstration purposes.
This works the first time, but then after that the code in the if statement never runs again. In fact, it seems like the line overlap_c = overlapping_tasks
is running every single frame. What’s even weirder is that when I had a version of this that ran every second instead of every frame, each second paused before running the line overlap_c = overlapping_tasks
functions completely normally (I even had a counter to make sure and the counter was updating).
Does anyone know what is causing this and how I can avoid/fix this? My full code for the node is down below
var overlapping_tasks = []
var overlap_c = []
func _process(delta):
if overlap_c != overlapping_tasks:
overlap_c = overlapping_tasks
print("YAY")
overlapping_tasks.append(0)
print(overlapping_tasks == overlap_c)
I’ve done some testing at it seems like the problem lies within the line overlap_c = overlapping tasks
. It seems like there’s is an issue where after running that the two variables seem linked together, where no matter what I do to one the other receives the same change.
I’ve managed to get it working though, as I have replaced that line with
overlap_c.clear()
overlap_c.append_array(overlapping_tasks)
That doesn’t seem like the most efficient way to solve the problem but it works for now
Goodman599 | 2022-08-04 23:21