#Piece splitting problem
1 messages · Page 1 of 1 (latest)
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.
you dont need to run lots of foreach loop in every object in every update
logging what instantiated an object would do nothing
I'm not really sure what to do right now
Well, start from thinking about what you're trying to do and whether it involved hundreds of instantiations each frame.
Write down the logic of what you're trying to do. Does it correspond to what actually happens?
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
Well, debug the logic responsible for them breaking.
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
not only are the hole fills breaking it, but they split into individual pieces
imma do some more debugging
alright @brazen ridge I think we got something
somehow there's 5 pieces being created, each with one piece inside and two just empty
I'm still baffled by the fact that the holes that aren't even close to the fragments are causing them to break
Well, how are you checking if they are close or not
And is that what you expect to happen or not?
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
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.
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
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.
but it is
It runs right after instantiation.
As part of the instantiation to be precise
This kind of complex logic shouldn't handled in the awake of the new pieces. It should be in the manager probably.
yeah..
we can now do the whole splitting thing
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
ok so something is really broken
somehow those two pieces split off properly
What code creates these pieces?
SplitHandler function
Debug the objects that you instantiate then. The empty should be among them
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?
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
like this, right?
Yes.
I run the game. Nothing happened when I pushed it into the wall
I mean the breakpoint seemingly did nothing*
Did you attach the debugger?
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.
Inspect in the debugger.
something is extremely wrong
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
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...
It wouldn't help, since I don't know the logic of the game. These red squared don't mean anything to me.
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
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
A bit busy right now. Gonna have a look later.