#how to get path to current transform

1 messages · Page 1 of 1 (latest)

mossy mulch
#

i want get exact path of current transform that i will be able put into find() to get this exact result

gritty totem
#

there's no such thing as a path

mossy mulch
#

yes

gritty totem
#

the current transform is always just "transform" you don't have to find it

mossy mulch
#

for other script

gritty totem
#

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

mossy mulch
#

great now i have to drag drop 5000 objects as each object has own script

#

that why wanted purely code sided solution

gritty totem
#

?

mossy mulch
#

plus it resets anyway when changing platform

gritty totem
#

show me wtf you're trying to do

#

you showed me one line of code

mossy mulch
#

thats whole script

#

i "optimized" it

gritty totem
#

so nothing is calling interact?

#

that's pretty dumb

mossy mulch
#

ah no vrchat does

#

when i click on object

#

interact run automatically when i click on the hitbox

gritty totem
#

can you change the signature of interact

#

just like

#

what fucking transform are you trying to access

#

show me the gameobjects

mossy mulch
#

as you see names repeat so wanted use path instead

gritty totem
#

i want to see the components involved

mossy mulch
#

which ones

#

like of which object

gritty totem
#

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

mossy mulch
#

just collideres and meshrenderers

#

besides path objects which also have script

gritty totem
#

when i say show me

#

i don't mean vaguely explain

#

sorry i should be more clear

mossy mulch
gritty totem
#

how is it referencing this script of yours

mossy mulch
#

it doesnt

gritty totem
#

HOW DOES IT CALL INTERACT

mossy mulch
#

it only changes name of certain object

#

ah

#

its built in into udon

#

you press on hitbox = interact runs

gritty totem
#

how

mossy mulch
#

i have no idea

gritty totem
#

where

#

you must configure it somehow

#

oh i see it's just part of the UdonSharpBehaviour thing

mossy mulch
#

do you mean my other script

gritty totem
#

okay so what are you trying to reference

#

in interact

mossy mulch
#

i dont know anything about udon i just used function for interaction

gritty totem
#

i have object "100" what am i trying to do

#

with the screenshot you showed me. what is THIS OBJECT trying to do

mossy mulch
#

name change just that

#

of the parent

#

so path(30)

#

hoever

gritty totem
#

WHAT

mossy mulch
#

lowergroundlayer also have same script

gritty totem
#

omfg

#

so its parent

mossy mulch
#

so i needed to somehow differ which one runs which

gritty totem
#

that's what you're asking

#

you want the name of the parent

mossy mulch
#

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

gritty totem
#

like this?

#

every object should reference its parents name?

mossy mulch
#

lets say

#

wait

gritty totem
#

just yes or no

#

is my image what you're trying to do

mossy mulch
#

not exactly

#

lowergroundlayer and 100 use same script

gritty totem
#

yes

#

and you want them both to reference path (30)

#

RIGHT?

#

or wrong

mossy mulch
#

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

gritty totem
#

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

mossy mulch
#

okay then maybe other question

#

can i rename all lowergroundnames to have unique names

#

in easy way

gritty totem
#

what is lowergroundname

#

i don't see that in the screenshot

mossy mulch
#

layers

#

miss

#

just so they all be unique

#

so i wont be needing any code changes then

gritty totem
#

why do you want them to be unique

mossy mulch
#

because my second script

#

have filter ready already

#

but its working by string

#

and since all of these have same name

#

it fails

gritty totem
#

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

mossy mulch
gritty totem
#

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?

mossy mulch
#

line 347 and all stuff around

gritty totem
#

wtf is happening here

#

what is this script on

#

show me the gameobject that this script is on please

mossy mulch
#

digtarget is exactly what i got from first script

gritty totem
#

HEY

#

can you show me what this script is on

#

pretty please

mossy mulch
#

what you mean

#

ah

gritty totem
#

show me

mossy mulch
#

gui

gritty totem
#

which gameobject

mossy mulch
#

ok

gritty totem
#

this script

#

is on

#

please

mossy mulch
gritty totem
#

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

mossy mulch
#

much better than finds from what i heard

gritty totem
#

find is also fucking stupid

#

what is happening here

mossy mulch
#

that means its the 100 object

gritty totem
#

why does this line exist. explain to me in simple terms what this if statement is doing

mossy mulch
#

thats how script finds out its the 100 object

#

then lower else defines that its not 100 object but lowergroundlayer

gritty totem
#

so why does lowergroundlayer need to have a unique name for every prefab instance

#

looks like you need it to be EXACTLY this name

mossy mulch
#

because there thousands of lowergroundlayer

gritty totem
#

so what

mossy mulch
#

i need unique names or different script

gritty totem
#

WHY

mossy mulch
#

because it always targets first one

gritty totem
#

you haven't explained to me what this chunk of code is doing

#

what is "it"

mossy mulch
#

ah

gritty totem
#

what is "first one"

mossy mulch
#

find(lowergroundlayer)

gritty totem
#

assume i can't literally read your mind and know innately what your game does

mossy mulch
#

finds first one

#

and errors

gritty totem
#

so don't use find

#

the same old advice you've been given every. single. day

mossy mulch
#

how would i get path to this object other way then

gritty totem
#

there's no such thing as a fucking path

#

idk what you mean by path

#

you mean a reference?

mossy mulch
#

same path that find uses

#

getchild/parent is path changes too

gritty totem
#

i'll repeat myself

#

DON'T USE THIS

#

serialize. a reference

mossy mulch
#

drag drop one?

gritty totem
#

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

mossy mulch
#

i was fixing my major issue

#

high loading times

#

its now fixed

gritty totem
#

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

mossy mulch
#

drag dropables always reset so thats even worse

gritty totem
#

NO THEY DON'T

#

what the fuck are you talking about

mossy mulch
#

they do when i change platform

gritty totem
#

???????

#

no they dont

mossy mulch
#

from android to windows

#

yes they do

gritty totem
#

you're editing in play mode. or not saving

#

my dude i literally do this for my job, they dont

mossy mulch
#

probably didnt worked with udon then

#

because i tested

gritty totem
#

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

mossy mulch
#

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?

gritty totem
#

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

mossy mulch
#

but do prefabs hold colliders,meshes,etc

gritty totem
#

prefabs are literally just preconstructed gameobjects

#

if it can exist in the scene, it can be a prefab

mossy mulch
#

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

gritty totem
#

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

mossy mulch
#

i wanted use transform variable instead

#

but no idea how to pass it to another script

#

so can i turn transform to string

gritty totem
#

transform cannot turn into a string

#

they're two different data types

#

i don't know what you mean by turn transform into string

mossy mulch
#

transform = string inputable to find

#

aka path

#

can be gameobject too

#

something like this

grim ice
#

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

gritty totem
#

@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

grim ice
#

Yeah, I see

gritty totem
#

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

mossy mulch
#

of course

#

fps = good enough

#

but once again im saying i dont care about fps now

#

but loading times

grim ice
#

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

mossy mulch
#

no

#

because

#

all scripts besides gui are off by default

grim ice
#

What is the cause of long loading times then?

mossy mulch
#

the fact 10k objects have their own scripts

#

check out new thread i made

grim ice
grim ice
mossy mulch
#

how im supposed to make blocks world like minecraft then

grim ice
#

Google how minecraft is done 😂 . Not by using millions of game objects atleast

mossy mulch
#

still every cube needs collider and way to interact with it

grim ice
#

Spoiler: they use one object per chunk (afaik)

mossy mulch
#

that would require replacing whole chunk

grim ice
#

Replacing by what?

mossy mulch
#

and im sure unity can handle few thousands objects

#

by new chunk after each block mined

grim ice
grim ice
mossy mulch
#

my game not suffers from lag but loading time

#

very first one

grim ice
mossy mulch
#

and i dropped from 4 minutes loading time to 1 minute already

#

so you might want help out drop it little more

grim ice
mossy mulch
#

that what i started with

grim ice
#

And it was even worse

mossy mulch
#

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

grim ice
mossy mulch
#

then where game will be then

grim ice
#

Chunks

#

Not cubes

mossy mulch
#

but that seem same

grim ice
#

Its not

mossy mulch
#

i will have to rescan whole chunk instead of just block

#

how im supposed to add colliders to it

grim ice
#

Mesh collider? Punch of box colliders?

mossy mulch
#

but mesh collider is whole

#

not just for one box

#

how would i get specific object i point at

grim ice
#

By using math

#

And having the block data as array on every chunk (one array element per block)

mossy mulch
#

sounds like remaking everything to do this

grim ice
#

Yes, they way you are doing is terrible

mossy mulch
#

so maybe starting with raycast detecting is good start

#

as i will need it in both cases

grim ice
#

Maybe

mossy mulch
#

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)

grim ice
mossy mulch
#

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

grim ice
mossy mulch
#

i try that later

#

Debug.DrawRay(_localPlayer.GetTrackingData(Head).position, transform.TransformDirection(Vector3.forward), Color.red, 1f);