#Proper way of cloning gameobjects

1 messages · Page 1 of 1 (latest)

snow bramble
#

i have a method where i place a cube at that position where i want duplicated object and it works

#

so i guess theres some problem with duplication

fringe roost
#

cause passing position should work fine

#

unless the position was wrong

#

Instantiate literally clones an object

snow bramble
#

it justs stays on default position

#

i mean the original position where is the object which i want to clone

flat krakenBOT
snow bramble
#
for (int x = -10; x <= 10; x++)
{
    if (x != 0)
    {
        bool placeTree = false;
        if (Math.Abs(x) > 5 && new System.Random().Next(3) == 0) placeTree = true;
        
        if (placeTree)
        {
            string[] trees = {"Oak_Tree", "Poplar_Tree"};
            GameObject tree = Instantiate(GameObject.Find(trees[new System.Random().Next(trees.Length)]));
            tree.transform.position = new Vector3(prevoffset + x, 1.5f, -z);
            tree.transform.rotation = Quaternion.identity;
        }
    }
}
fringe roost
#

so where is prevoffset and -z coming from

snow bramble
#

set those to 0 i am excited if it will work for you just on x axis

fringe roost
snow bramble
#

for now yes

#

the variable is prepared for future content

fringe roost
#

I still don't see whats wrong

snow bramble
#

idk too that's why i am asking :D

fringe roost
#

its hard to tell from here

#

make a vid , or screenshot with some lines

snow bramble
#

sure

#

hmm i figured out a better explanation

#

it sets the position as of now but it stays on origin position

#

but the position is set as i want

fringe roost
#

so its solved?

snow bramble
#

no, its not

#

how can i update it?

snow bramble
fringe roost
snow bramble
#

i mean the position of duplicated object is right

#

but it is displayed on origin position

fringe roost
snow bramble
#

the position of cloned object is right but it is displayed at the origin regardless setted position

fringe roost
#

wdym displayed at the origin

#

you still havent explained what that means

snow bramble
#

the position of object that i am trying to duplicate

fringe roost
#

that makes no sense

#

I dont see that assigned anywhere to tell the clone to spawn there

snow bramble
#

well its like display bug or smth

fringe roost
#

hows it a bug if you havent assigned it anywhere

snow bramble
#

wdym?

#

i assigned clone a position or not?

fringe roost
#

how that related to the object you want to clone

snow bramble
#

when prevoffset is 0 it should be -10

#

or?