#I checked and all of the gameobjects are

1 messages · Page 1 of 1 (latest)

shadow hemlock
#

Can you run me through your problem again? I'm trying to piece it together, but it got lost in all the messages haha

steady lily
#

IM SORRY! i had to go eat

#

essentially, im trying to destroy block thats part a prefab, without breaking the actual prefab

#

more info is here

#

"soo could anyone help me with destroying just the instance of a prefab? currently im trying to destroy whatever object touches me. but it also destroys the actual prefab, not that induvidual instance

#

so if i ever want to summon the prefab again, its missing all of the parts i destroyed"

shadow hemlock
#

Hmmmm

#

What is the role of this in the destroy method?

#

Is that how you work with prefab instances?

steady lily
#

to get this script, and then the gameobject

steady lily
#

:)

#

holy crap that seemed so passive aggresive on a second read mb

shadow hemlock
#

Not very good with them yet

steady lily
#

*yet

shadow hemlock
#

Let's see if we can figure it out

#

So I'm not seeing where the instance of the prefab is instantiated

steady lily
#

wdym?

#

ohhh

#

no its in a seperate script

#

ill pull it up

#

big block of code but im not sure which parts are important to you

shadow hemlock
#

Aha

#

So I'm new to unity as well, but I'm a software engineer

steady lily
#

(yes there is lego terrain, yes this is a game jam)

shadow hemlock
#

And I'm wondering if this means anything at all

#

It would make sense in something like JavaScript

steady lily
#

well it only runs when destroying the threshold.

#

or chunk loader, whatever you want to call it

#

HOLD ON I GOT IT

shadow hemlock
#

Hmmm

steady lily
#

ITS DESTROYING THIS GAMEOBJECT

#

NOT THIS INSTANCE

#

at least i think lol

shadow hemlock
#

What is this game object? I'm not sure what this script is attached to

steady lily
#

its attached to the chunk loader

#

so if the player runs into an invisible super tall object, this runs

shadow hemlock
#

Hmmm

#

Possibly

#

What if you do Debug.Log(this)?

steady lily
#

i could try

shadow hemlock
#

Let's see what it spits out

steady lily
#

i put it in the projectile's script, should i put it in the chunk loader one too?

shadow hemlock
#

Wherever you're calling destroy

#

I'm also surprised it's not complaining about the recursion in the destroy method you define

steady lily
#

in which script?

#

oh the bite one

shadow hemlock
#

Yeah

steady lily
#

i have crappy code, and the cooldown hasnt been implemented for the bite yet so the log is just filled with the same log

#

might take a minute to fix at most tho

shadow hemlock
#

No worries

#

There's no such thing as bad code

#

Only bad choices

steady lily
#

there you go

shadow hemlock
steady lily
#

....

#

i think im close mabye?

shadow hemlock
#

Haha

#

It seems it's just understanding it as some sort of object

steady lily
#

creating a new chunk loader makes it work fine

#

im wondering if its cloning itself instead of the prefab

#

is it possible to find objects that are only in your files, using code?

#

nvrmind thats a google question oops

shadow hemlock
#

Hmmm

#

So walk me through the chunk loader's logic

steady lily
#

when you walk into it it summons a random prefab from one of 3 arrays, at the end of each prefab or "chunk", theres always another chunk loader

#

so theoretically thats infinite generation

shadow hemlock
#

If a player collides with it, and the "game controller" is grassy, it does something

#

Oh I see

#

So lemme try to say it back to you to see if I understand

#

You've got a chunk of playable area

steady lily
#

havent coded the other terrains yet but their the exact same

shadow hemlock
#

And when the player reaches the edge, you want to spawn another chunk where they went to

shadow hemlock
#

And you want the same thing to happen if the player reaches the edge of that chunk too

steady lily
#

if there's a way to find gameobjects through files then my problem is fixed

shadow hemlock
#

Ok I think we need to step back a little bit

steady lily
#

OK

shadow hemlock
#

I think part of the problem is the chunks are managing part of the system that spawns other chunks

#

It's basically a house of cards

#

I think you need a separate thing that manages the spawning

steady lily
#

I think that would work much better than what im doing actually

shadow hemlock
#

I think the chunks need to be decently removed from that process

steady lily
#

i could also keep an offscreen instance of each terrarin prefab, and reference that to make sure i get the actual prefab instead of the wrong one, but that bring many more problems than your idea

#

sooo is that the fix? thank you so much for your help, like seriously. between homework and other stuff I haven't had the brainpower to fix this but you've been a lifesaver

#

:)

shadow hemlock
#

I think the chunks can fire an event or something when something enters the region of the chunk that triggers the spawning

#

Or maybe the main controller can simply manage the collision objects for where it knows it hasn't spawned chunks yet but might need to

steady lily
#

*am

shadow hemlock
#

Nice

steady lily
#

well i finally have an excuse to play around with for loops

shadow hemlock
#

Excellent

#

Don't forget about foreach loops. Those are handy