#My game thingy

1 messages · Page 1 of 1 (latest)

idle pike
#

{
if (StrtPos == Vector3.zero)
{
for(int x = -radius; x < radius; x++)
{
for (int z = -radius; x < radius; z++)
{
Vector3 pos = new Vector3((x * planeOffset + XplayerLocal), 0, (z * planeOffset + ZplayerLocal));

                if (!ChunksPlane.Contains(pos))
                {
                    GameObject _plane = Instantiate(plane, pos, Quaternion.identity);
                    ChunksPlane.Add(pos, _plane);
                }
            }
        }
    }
#

the problem area

ionic quartz
#

A lot easier if you post code like this

CODE
idle pike
#

oh ok

ionic quartz
#

Easier to read at least

idle pike
#

video i got the code from

quasi delta
#

now look very very closely at the variables being used in your for loops

idle pike
#

so the begining is checking for planes being spawned around the player
and the second part checks if the planes are being spawned around the player and if they are, we want x to increase

#

i think ive figured it out

quasi delta
#

literally just what is different about these two loops

for(int x = -radius; x < radius; x++)

for (int z = -radius; x < radius; z++)
idle pike
#

is that right man?

quasi delta
#

what is different about those two loops

idle pike
quasi delta
#

is it?

#

look again

#

pay attention to only the two lines i just copied from your code

idle pike
#

yep i just watched the tutorial again and thats basically what the guy said

quasi delta
#

sure that's what the tutorial's code does. look at the fucking code that you wrote that i just pasted in this chat. what is the difference between the two lines

idle pike
#

literally x and z are swapped, it checks for if you are moving x or z and if you are it adds more onto x or z apart from that the only difference is the space

quasi delta
#

look closer

ocean brook
#
for (int z = -radius; x < radius; z++)
idle pike
quasi delta
idle pike
quasi delta
#

you're thinking about it at too high of a level
what does each specific part of the loop do. without associating it with the rest of your code.

#

for example:

for(int i = 0; i < someArray.Length; i++)

this loop creates an integer called i equal to 0, it checks whether i is less than the length of someArray, then it increases the value of i. the next iteration of the loop will then check if the now larger value of i is still less than the length of someArray

idle pike
#

and the x is the error

#

took me a while, well im guessing thats the error

quasi delta
#

depends on which x you mean, but yes. x is the error

idle pike
#

yeah the video was a really poor quality, i must have missed it

quasi delta
#

this is why i was stressing to pay attention to the variables you were using in your loop

idle pike
#

thanks anyway, sorry for getting so stressed out there

#

sometimes i kinda just dont see things

#

man that was releif when the game actually worked

#

but tbh you didnt need to do that whole fiasco cause of a typo