I am creating a 3d runner game in which I Am able to spawn blocks on a long ramp but they are spawning at the same position and not moving forward as player, I want to ask that How to spawn blocks with a increment on z axis the next time I spawn Blocks

I am creating a 3d runner game in which I Am able to spawn blocks on a long ramp but they are spawning at the same position and not moving forward as player, I want to ask that How to spawn blocks with a increment on z axis the next time I spawn Blocks

float lastDepth = 0.0F;
float incr = 1.0F; // How much you want to increment on Z.
void SpawnBlock () {
Vector3 vec = new Vector3 (0.0F 0.0F, lastDepth);
Instantiate (blockPrefab, vec);
lastDepth += incr;
}

@prashantk807 Call this function where you would normally spawn the object from. Modify it to suit your needs.