#Piece splitting problem

1 messages · Page 1 of 1 (latest)

wise zenith
#

@brazen ridge let's continue here

brazen ridge
#

Ok, so if each of these 111 is instantiating many objects as well, that's gonna kill the framerate. And if that's happening each frame, that's gonna cause a freeze.

#

So might want to investigate these 2 things.

wise zenith
#

yeah it froze already

#

So now I backtrack or add another debug log?

late python
#

you dont need to run lots of foreach loop in every object in every update

wise zenith
#

logging what instantiated an object would do nothing

wise zenith
brazen ridge
#

Write down the logic of what you're trying to do. Does it correspond to what actually happens?

wise zenith
#

What I'm trying to do is to split the piece if there' more than 1 group of fragments inside it. Fragments detect adjacent fragments of the same piece and set their group integers. Then a dictionary of empty lists is made and filled with the fragment lists. In the if statement, I wanted to create a new piece for each group and move corresponding fragments there (I tweaked the last if statement a bit to account for more than 2 groups but now all pieces break instantly the second a room is loaded.

#

I think this brings us a step closed

#

because we just create a piece for each group

#

and MOVE the fragments from the original

#

but instead every fragment is instantly broken

#

lemme record it

#

the only reason all rooms aren't immediatelly cleared is becase of a interacted bool each room has which is a debugging step I added in case a room wants to clear instantly

#

so now, somehow, pieces just break the instant their room's ID is the current one

brazen ridge
wise zenith
#

ok, might take a second

#

they are definitely not breaking due to the wall breaking function

#

as only the brittle wall was broken (as intended in the room)

#

alright

#

somehow it's detecting holes

#

I'm gonna delete the hole fill functionality (comment out) and see if they even split

#

ok so here's something odd

#

imma do some more debugging

#

alright @brazen ridge I think we got something

#

I'm still baffled by the fact that the holes that aren't even close to the fragments are causing them to break

brazen ridge
#

Well, how are you checking if they are close or not

brazen ridge
wise zenith
#

no, what I expected is 2 pieces, one with two fragments, another with one fragment

#

because I expected one piece per group of fragments

#

I think the hole part is caused by the Awake not doing it's job

#

after a piece is created and all that

brazen ridge
#

I don't know what logic you're running and what it's supposed to do. So that doesn't tell me anything. If you give me specific pieces of code that you think don't do what you expect, I might be able to give an advice.

wise zenith
#

I understand

#

tho the hole problem might be caused by this. I assume Awake runs before the next frame, not right after creating an object?

#

wait no

#

wtf

#

I suspected that's because this value is 0

brazen ridge
#

If you see lore objects than you expect than either:

  • the prefab had more objects than you expect
  • you're instantiating more than you expect.

The first one can be confirmed by looking at the prefab.
The second by looking at the code.

wise zenith
#

but it is

brazen ridge
#

As part of the instantiation to be precise

wise zenith
#

damn

#

ok, holes are fixed

brazen ridge
#

This kind of complex logic shouldn't handled in the awake of the new pieces. It should be in the manager probably.

wise zenith
#

yeah..

#

btw the level isn't passing because those empty pieces are created

#

so something is wrong with that

#

I mean they are legit pieces

#

imma add another fragment

#

because I suspect it creates a piece for every fragment in the object instead of group

#

somehow those two pieces split off properly

brazen ridge
#

What code creates these pieces?

wise zenith
#

SplitHandler function

brazen ridge
#

Debug the objects that you instantiate then. The empty should be among them

wise zenith
#

look it's still 5 pieces. two for the things that disappeared, two for the left ones and one for the part sticking out

#

I mean we know what was instantiated because it appears in the hierarchy

#

or did you mean something else?

brazen ridge
#

I mean, that would help you understand why they are spawned

#

Even better, place a breakpoint and see how many objects are instantiated and why

wise zenith
#

like this, right?

brazen ridge
#

Yes.

wise zenith
#

I run the game. Nothing happened when I pushed it into the wall

#

I mean the breakpoint seemingly did nothing*

brazen ridge
#

Did you attach the debugger?

wise zenith
#

damn my fault, one sec

#

we get this

#

if you need me to move or zoom, just say

brazen ridge
#

Inspect the relevant variables, like the fragmentGroups and the children of the newPiece as you step through the code.

#

I'd suggest learning the basics of using the debugger. It's very useful if you know what to do.

wise zenith
#

yeah... I'll do that soon

#

tho, what should I do now? Inspect as in debug log?

brazen ridge
#

Inspect in the debugger.

wise zenith
#

something is extremely wrong

brazen ridge
#

You can hover over variables to see their values and contents

#

And you can step through the code(F10 and F11) to how it executes

wise zenith
#

I don't know how to explain in words what happens in there

#

should I record it?

#

do you need the Fragment class' script?

#

man, this is such a mess...

brazen ridge
#

Maybe explain what should be happening and what actually happens, and share a video

#

Explain it such that a person that sees your game for the first time would understand

wise zenith
#

Rooms are made of elements, some of them are Pieces, which are red blobs you move into holes. Pieces are made up of fragments which gives them their shape and functionality. By moving pieces into a row or column with brittle walls (dark net pieces in the room) with only fragments and brittle walls between two regular walls, the row/column of fragments and brittle walls will be deleted. This results in changing the shape of the piece by removing it's inner fragments. After that, in the next frame, we'd run a function that determines whether the piece being cut resulted in gaps or not, by making each piece set itself a new group, then run a function that checks if it's adjacent to any fragments of the same piece and no group (aka the group is 0). Then, that piece runs the function and so on, supposedly spreading the group across any amalgamation of fragments. This happens once per piece and is reset before starting to prevent cross-piece grouping. Then, what the function is supposed to do, is create a new piece for each group found, and move it's corresponding fragments out of the initial piece that was cut and into their pieces, and later deleting the original piece, which would result in a clean split no matter how many groups were created through cuts at once.

What happens now is a bit weird. In one room the pieces split into individual fragments the moment a room is loaded, in another they're in tact until you clear a line with them. Then, not only do they split into individual fragments, but the ones removed get their own pieces and some actually get grouped properly.

This results in a total mess of possibilities for the function not running properly. We don't know if it's caused by Pieces, Rooms of the roomHandler, but it's almost 100% certainly one of these three causing it.

#

is this alright

#

tho please ping me once you read it, I need to start making dinner

#

@brazen ridge as a last resort I can just start over the entire mechanic

brazen ridge
#

A bit busy right now. Gonna have a look later.