I've created 2 instances and both are using the same function. How to make them independent?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fagnerln

I’ve created 2 instances and both are sharing the same function (or a nodes that acts on both, or variables, maybe? - IDK exactly).

I’m developing a puzzle game that everything moves by a timer, the blocks, the AI, etc. If some action happen, like a block falling or destroying, those timers stops, until the game is ready to resume. I have a function to pause (paused = true)those timers, and one to resume (paused = false). It works perfectly fine in single player.

But my idea is to make it multiplayer too, so I created 2 instances of this base, which works fine, but I noticed that when a block from a instance are destroyed or falls, it pauses both instances.

How to make those instances independent?

Oh man. It was just me being stupid.

Think, doesn’t make any sense to a node or a function or whatever in a packed scene control another packed scene in the same level if it’s not explicit with a signal.

I tried to create timers on the code, created different timers, I put a lot of match on the code, and it never works.

So I start to look the whole code of the scene (just 600 lines + 600 of AI) and I found it.
One of the conditions to resume the timer is to check if a group “destroyed” still have nodes. So if a player destroy some block, if the other player drops a block for example, the clock of the second will resume only if the blocks of the first player are completely destroyed.

The funny thing is that this group are mentioned in only 2 lines.

It was fixed putting (“destroyed” + str(player)) when referring to the groups.

:bust_in_silhouette: Reply From: Inces

I guess you are using signals to make timers paused ?
If so, than You should individualize those signals and connect them to specific timers.
If not, then show us this part of code

I found the problem, I was using groups to resume the timers. I edited the post.
Thank you for your time

fagnerln | 2021-03-09 22:21