#how to get path to current transform
1 messages · Page 1 of 1 (latest)
there's no such thing as a path
yes
the current transform is always just "transform" you don't have to find it
for other script
you can pass a reference to the transform
public class Foo : MonoBehaviour
{
public void DoSomething(Transform context)
{
Debug.Log(context.gameObject.name);
}
}
public class Bar : MonoBehaviour
{
private Foo _foo;
private void CallDoSomething()
{
_foo.DoSomething(this.transform);
}
}
tada
no "paths" needed
great now i have to drag drop 5000 objects as each object has own script
that why wanted purely code sided solution
?
plus it resets anyway when changing platform
ah no vrchat does
when i click on object
interact run automatically when i click on the hitbox
can you change the signature of interact
just like
what fucking transform are you trying to access
show me the gameobjects
i want to see the components involved
the ones INVOLVED
in whatever the fuck you're trying to do
the components that have the interact script, and the components that operate on the interact script
how is it referencing this script of yours
it doesnt
HOW DOES IT CALL INTERACT
it only changes name of certain object
ah
its built in into udon
you press on hitbox = interact runs
how
i have no idea
where
you must configure it somehow
oh i see it's just part of the UdonSharpBehaviour thing
do you mean my other script
i dont know anything about udon i just used function for interaction
i have object "100" what am i trying to do
with the screenshot you showed me. what is THIS OBJECT trying to do
GameObject.Find("chipqueue").transform.GetChild(0).name = transform.parent.name;
name change just that
of the parent
so path(30)
hoever
WHAT
lowergroundlayer also have same script
so i needed to somehow differ which one runs which
i would want but
lowergroundlayer
all of these have same name
so script cant differ which one to take
so find dies and i need something like transform instead
if its lowergroundlayer then i want to reference itself
because thats different layer already
and since it referencing itself it cannot be differed as there thousands of lowergroundlayers
make path a fucking prefab dude
configure 100 to reference its parent, configure lowergroundlayer to reference itself
then spawn the prefab 1000 times, they'll all be configured identically
you're way over complicating it
okay then maybe other question
can i rename all lowergroundnames to have unique names
in easy way
layers
miss
just so they all be unique
so i wont be needing any code changes then
why do you want them to be unique
because my second script
have filter ready already
but its working by string
and since all of these have same name
it fails
idk what your other script is doing
are you talking about layermasks
can you show me the other script x.x
i feel like this is just an endless hell and you're fucking with anyone who is willing to help
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
ok so what's the thing in this script that requires the gameobject's name to be unique
this is a script on the layer object?
line 347 and all stuff around
wtf is happening here
what is this script on
show me the gameobject that this script is on please
digtarget is exactly what i got from first script
show me
gui
which gameobject
ok
this kind of stuff btw
is like if i made a challenge to write the worst unity logic that technically compiles
would 100% win
it's incredibly fragile and has terrible performance
much better than finds from what i heard
find is also fucking stupid
so line 347 "digtarget.name != "lowergroundlayer"
what is happening here
that means its the 100 object
why does this line exist. explain to me in simple terms what this if statement is doing
thats how script finds out its the 100 object
then lower else defines that its not 100 object but lowergroundlayer
so why does lowergroundlayer need to have a unique name for every prefab instance
looks like you need it to be EXACTLY this name
because there thousands of lowergroundlayer
so what
i need unique names or different script
WHY
because it always targets first one
ah
what is "first one"
find(lowergroundlayer)
assume i can't literally read your mind and know innately what your game does
how would i get path to this object other way then
there's no such thing as a fucking path
idk what you mean by path
you mean a reference?
drag drop one?
or generate them procedurally and add them to a list
there's just so fucking much wrong with every script you show us though
like there's at least 500 major problems with this script
no you're not
almost every line in this script is a catastrophe
Getchild, Find, relying on gameobjects having exact names, this is all terrible
but you keep refusing to change it
it makes your code really fragile and hard to manage
and you're dealing with the consequences of that right now
just stop doing it this way
it's fucking bad
drag dropables always reset so thats even worse
they do when i change platform
you're editing in play mode. or not saving
my dude i literally do this for my job, they dont
show me
add a serialized variable. assign it in the inspector OUTSIDE of play mode. save your poject, switch platforms
and show me that it's no longer assigned
it doesnt change every time
plus there still no space to do it when 5000 objects use their own object
unless you mean
i should pass transform from first script to second one
can i change public variable content like that?
i literally told you for the third time that you can use a PREFAB
if you're manually creating 5000 near-identital objects you need to be using prefabs
but do prefabs hold colliders,meshes,etc
prefabs are literally just preconstructed gameobjects
if it can exist in the scene, it can be a prefab
okay i will remake my map later
meanwhile i cant add public variables because udon has different way of accessing them
and i totally dont know how
so i still wonder how to rename all objects to unique names
they don't have to be unique names
you just have to design your system in a less terrible way
i'm telling you
AGAIN
for the 500th time
relying on SPECIFIC transform indexes, EXACT names, and using find and getcomponent everywhere is TERRIBLE
it's the root of every problem you have
and you refuse to stop doing it
this is why everyone is sick of trying to help you
because they give you the best advice possible and you argue
i wanted use transform variable instead
but no idea how to pass it to another script
so can i turn transform to string
transform cannot turn into a string
they're two different data types
i don't know what you mean by turn transform into string
transform = string inputable to find
aka path
can be gameobject too
something like this
Thats just terrible. Youre obviously ending up using finds and getcomponents to turn that string into transform again right? Only advice I can give is to start by doing something much simpler and learning proper ways to keep track of references without relying in finds and getcomponents
@grim ice he's determined to not change a line of his code though
he's been in here asking about "finding the path of a transform" for months
and ignores EVERYTHING
Yeah, I see
and we tell him its shit every day
and he's like "nononno i optimized it"
and optimization means he moved all of the shit code outside of update
of course
fps = good enough
but once again im saying i dont care about fps now
but loading times
And once again we are trying to say that the way you are doing things is terrible which then reflects to everything like loading times
What is the cause of long loading times then?
Im not sure if I want to...
No, the fact that you have 10k objects, dont
how im supposed to make blocks world like minecraft then
Google how minecraft is done 😂 . Not by using millions of game objects atleast
still every cube needs collider and way to interact with it
Spoiler: they use one object per chunk (afaik)
that would require replacing whole chunk
Replacing by what?
and im sure unity can handle few thousands objects
by new chunk after each block mined
Nope, only few triangles needs to be edited
And im sure minecraft would suffer a lot with 50k objects too
But minecraft doesnt...
and i dropped from 4 minutes loading time to 1 minute already
so you might want help out drop it little more
I have solution, dont use 10k objects with script
that what i started with
And it was even worse
i removed all of the excessive code from the objects
now they just send request to another script
but removing script completely would be more optimal
so i want try out detecting objects by raycasting
Removing the gameobject completely would be optimal
then where game will be then
but that seem same
Its not
i will have to rescan whole chunk instead of just block
how im supposed to add colliders to it
Mesh collider? Punch of box colliders?
but mesh collider is whole
not just for one box
how would i get specific object i point at
By using math
And having the block data as array on every chunk (one array element per block)
sounds like remaking everything to do this
Yes, they way you are doing is terrible
so maybe starting with raycast detecting is good start
as i will need it in both cases
Maybe
and removing 10k scripts will be very good
okay so moment
instead of placing 3 same blocks on top of each other
its better to make new material with 3x blocks stacked already?
and just one object to display this
(non minable blocks)
From the raycast hit position and normal you can figure out which block of the chunk you just hit and and access that from the array/remove/whatever
no i mean i wont use raycast for this
the decorative blocks
for surroundings you cant mine
that way i could decrease current object count by like 2 times
Bit better but sounds complicated. Replace all the blocks by 128×128×128 (or similiar) chunks with single mesh. You can google the implementation of minecraft to see how the mesh generation for that chunk should be done