please help with my loop

i had just recently decided to get back into scripting so i am a bit rusty and need help with loop logic i am shrinking down the chunk / block distance between each other to 6.4.
the old code was working but i need to move it into a grid for the path finding system and cant work out the logic to scale down the integer from 1 or 0 to 6.4 the above image is what i have currently

 void CreateWorld ()
        {
    
            chunks = new Chunk[worldX + 1,  0, worldZ + 1 ]; // newccode
            for (int x = 0; x < worldX; x++)
            {
                for (int z = 0; z < worldZ; z++)
                {
                    //Vector3 p = Vector3.zero; old working code
                    //p.x += x * 6.4f; //this float moves the chunk distance //old working code
                    //p.z += x * 6.4f; old working code

                    RequestWorldGeneration(x, z, chunk_X , chunk_Z);  // new output
                    //RequestWorldGeneration(p);  // old working output
}

public void RequestWorldGeneration(int x, int z, int chunk_X, int chunk_Z)
        {
            WorldChunkStats s = new WorldChunkStats  //converts to object??
            {
           
                chunk_X = x,
                //chunk_Y = y,
                chunk_Z = z,
                //noise settings that will be used elevate tiles on the grid
                baseNoise = baseNoise, //0.04
        
                baseNoiseHeight = baseNoiseHeight, //6
                elevation = elevation,
                frequency = frequency,  //0.013
                origin = new Vector3(x * chunkSizeX , 0, z * chunkSizeZ ),
        
            noisePatterns = noisePatterns
            };

            WorldGenerator wg = new WorldGenerator(s, LoadMeshData);

            toDoJobs.Add(wg);
        }
int myInteger = 8;
float myScale = 6.4f;
float myValue = myScale * (float)myInteger;

though it will be coerced anyway. your error lies in typing a double, instead of a float
this is a double

6.4

this is a float

6.4f

thank you very much

now I see that you asked for an approach, it wasn’t just a type error.
don’t scale the increments, scale the whole thing as it is.

don’t do this

for(int x = 0; x < something; x++) {
  myCoords.x += scale * x; // this doesn't mean much
}

do this

for(int x = 0; x < something; x++) {
  var scaledCoords = scale * x; // you transform from one frame to another
  // use scaledCoords from now on
}

brilliant thank you again sir

i updated the main thread with a screenshot sir scaling wont change the individual chunks theres 16 chunks of 64 blocks

please use the code tags and fix the indentation of your code

like this

now, I can’t see that you’re setting the scale of your chunks anywhere in that code
my previous posts were general, without going into what you’re trying to achieve here

you need to set the objects’ transform’s local scale to some scaling vector

myObj.transform.localScale = new Vector3(myScale.x, myScale.y, myScale.z);

obviously myScale should be something other than (1, 1, 1), because that’s the default.
and you don’t want to set it (0, 0, 0) either, because that would scale each axis to nothing.

this is what got me off of what you want to do. the real question is ‘how do I scale up or down a gameobject’

the quads are scaled to 0.05f in their array their distance apart = interger 1 * .010f and there are 64 the simplex noise script only out puts intergers to give the blocks height this is created in a job handle for multithreadding the chunk is not threadded but now sits 1 interger apart and i am trying to decrease that distance as the screenshot indicates each block set is placed inside a game object in a grid called chunk the generator object passes the chunk objects to the parent object as xyz the distance between quads from a similar loop to the chunk[ ] array = Block Data[ ]

Vector3 targetPosition = Vector3.zero;
targetPosition.x += x * 0.10f;
targetPosition.z += z * 0.10f;

so you’re populating a grid, and want a configurable spacing…

scaling the parent object will still leave these gaps inbetween each chunk that is created in the loop

yes the object selected is already a 64 grid array each called block data the chunks are in a grid called chunk

using the inspector the other quads only need to go x 6.4 z 6.4 everything is created in runtime the verts the quads only thing i built is the texture each block has all faces that are being culled and at least 600 lines of code the code i had used did work im following a tutorial and my diploma lecturers said that using a such massive objects is stupid because unity has to calculate the thousands of float points they said top scale everything right down but as scale goes down then position becomes greater between the objects scaled i was only asking how to lessen the distance of the already scaled objects that are already in arrays

int the chunk array the blocks no longer exist as im not using dots im using a 2017 version of multithreadding

I understand, and I already gave you the code to populate the grid.
I don’t want to sound too harsh, but next time honestly admit that you don’t have a clue what you’re doing and that the code isn’t yours.

Because it makes zero sense to know about multithreading, culling and whatnot, if you’re not knowing how to properly position objects in the scene. I’m guessing Google isn’t up your alley? Just about any Unity example, ANY, would teach you how to do it with a single line of code. Sigh.

mySpacing = new Vector2(6.4f, 6.4f);
for(z ... )
  for(x ... )
    myObj.transform.position = new Vector3(mySpacing.x * x, 0f, mySpacing.y * z);
  }
}

Here, let’s go back to the beginning.

i been using my game development diploma notes from 2 years ago

heres one of my diploma assesments
i could not do this off the bat either

using UnityEngine;
using UnityEngine.Networking;

[NetworkSettings (channel = 0, sendInterval = 0.04f)]
public class NetworkTransform_Custom : NetworkBehaviour {

   public float lerpRate;
   [SerializeField]
   Transform playerPrefab;
   //[SerializeField]
   //Transform playerCamera;

   [SyncVar]
   private Vector3 syncPos;

   [SyncVar]
   private float syncRotY;

   public int snapThreshold = 5;

   //[SyncVar]
   //private float syncRotX;


   void Update ()
   {
       TransmitSync ();
   }

   void FixedUpdate ()
   {
       LerpTransform ();
   }

   void LerpTransform ()
   {
       if (!isLocalPlayer)
       {
           if(Vector3.Distance (playerPrefab.position, syncPos) > snapThreshold) {
               playerPrefab.position = syncPos;
           }
           playerPrefab.position = Vector3.Lerp (playerPrefab.position, syncPos, lerpRate * Time.deltaTime);
           playerPrefab.rotation = Quaternion.Lerp (playerPrefab.rotation, Quaternion.Euler (0, syncRotY,  0), lerpRate * Time.deltaTime);

           //playerCamera.rotation = Quaternion.Lerp (playerCamera.rotation, Quaternion.Euler(syncRotX, playerCamera.rotation.eulerAngles.y, 0), lerpRate * Time.deltaTime);
       }
   }

   [Command]
   void CmdSyncTransform (Vector3 pos, float rotY)
   {
       syncPos = pos;
       syncRotY = rotY;
       //syncRotX = rotX;
   }

   [ClientCallback]
   void TransmitSync ()
   {
       if (isLocalPlayer)
       {
           CmdSyncTransform (playerPrefab.position, playerPrefab.rotation.eulerAngles.y);
       }
   }

}

something from my desktop
Monday, 28 September 2015
John Riwhi
Dear John
Re: Letter of Acceptance
Thank you for your application in the Cert IV Digital & Interactive Games program.
I am pleased to advise that you will be offered a place in the program for Semester 1, 2016.
What to do next
At the end of November, 2015 you will be able to register for your program.
You will be sent a Letter of Offer, Enrolment Checklist and How to Register Guide before that time. Follow the instructions and register for your selected program and subjects.
Should you require any further information, please contact the Department on either 95641796 or it@holmesglen.edu.au.
We trust your study experience will be both enjoyable and rewarding and we look forward to welcoming you to Holmesglen.
Yours Sincerely,
Bradley Alderson Head of Department Computing and Information Technology

Time for civil minds.

1 Like