#Infinite spawn issue

1 messages · Page 1 of 1 (latest)

livid pollen
#

Figured this would be easier XD

high radish
#

I mean it sounds like you already identified the issue

#

you are spawning infinite rooms

#

stop doing that

livid pollen
#

Im not trying too

#

Thats the issue

stark stratus
#

You're not adding to Rooms when you spawn a room

livid pollen
#

private void Start()
{
Logic = GameObject.Find("Logic");
Logic.GetComponent<RoomHolder>().Rooms.Add(this.gameObject);
}

wheat eagle
#

where are you setting isTriggered to false?

stark stratus
#

or is there a SeedHolder on each room?

livid pollen
#

Each room does when its created

#

Seed for each

#

ye

livid pollen
stark stratus
#

I wonder if OnTriggerEnter runs the same frame you instantiate an object

#

I have never thought about that.

livid pollen
#

How would we even account for that

stark stratus
#

If that's true, then you'd get infinite rooms, since none would add to Rooms until the next frame

livid pollen
#

Maybe a delay?

#

Could i just do a invoke?

#

delay

stark stratus
#

Consider replacing Start with Awake.

#

This will run immediately upon instantiation

livid pollen
#

sure

#

Ill try

high radish
stark stratus
#

ah, good point.

livid pollen
#

Interesting

#

Awake didnt work

#

Ill try invoke cause I dont know a better option

stark stratus
#

I would attach a debugger to find out where it's stuck.

#

run game, get to the part that freezes, pause the debugger

high radish
#

yeah you seem to be missing the whole "debugging" phase of diagnosing this problem

livid pollen
#

Yea its full crashing it

#

I cant

#

really

stark stratus
#

oh, wait

#

Logic.GetComponent<RoomHolder>().Rooms.Add(this.gameObject);
if (Rooms.Count < 10)

livid pollen
#

Unless Unity has a crashlog debuggger

stark stratus
#

these are two unrelated lists

stark stratus
#

your editor isn't instantly crashing

wheat eagle
#

you also got an error, not sure if it is for this but it happens when the freezing starts

stark stratus
#

(that can happen if you get infinite recursion)

stark stratus
high radish
stark stratus
#

I don't understand why the SeedHolder is trying to iterate over a bunch of rooms

livid pollen
#

It maxes my ram and goes unresponsive

stark stratus
#

that isn't a crash

#

a crash is when the application completely quits

livid pollen
#

Sure

#

I stll cant click pause tho

stark stratus
#

yes, because it's frozen

#

it's not a crash. it's just stuck doing a huge amount of work.

stark stratus
#

I'm talking about attaching a debugger to Unity.

livid pollen
#

Oh like a seperate software

stark stratus
#

a debugger is a separate program that can monitor another process and interrupt it

#

Yes

livid pollen
#

I dont know how to do that

high radish
#

your IDE has a debugger

#

assuming you're using a decent one

livid pollen
#

Rider

high radish
#

yes just press the play button in rider

#

it attaches the debugger

#

also put down breakpoints

stark stratus
livid pollen
high radish
#

yep

#

but also set breakpoints first

#

by clicking in the margin of the code

stark stratus
#

well, in this case

high radish
#

for example a good spot would be on the Instantiate line

stark stratus
#

we don't need breakpoints

#

we're just hitting pause once it gets stuck

wheat eagle
#

and just click this "Debug"

stark stratus
#

Although, actually, no, they will still help. You might pause the game in some weird place if you just pause randomly.

#

So, yes, listen to Praetor 😛

livid pollen
#

I actually knew that how to do that part I just didnt realise my Rider & Unity worked together that much

#

Thanks

wheat eagle
#

error pause

#

if it shoots error that is, and it looks like it is

stark stratus
#

That is not the same.

#

Error Pause pauses at the end of the frame.

#

It will not help you if the editor is freezing.

#

Debug.Break() also pauses at the end of the frame

livid pollen
#

interesting]

#

So I tested with invoke and it stacked rooms weirdly

#

Before play

#

start of play

#

Entering the first room, so far so good