Created
January 19, 2014 15:58
-
-
Save Chronojam/8506797 to your computer and use it in GitHub Desktop.
Urgh movement.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Ship.transform.position.x > (activeChunkPosition.x * ChunkSize) + ChunkSize/4) { | |
// Make a new chunk in the direction we're going. | |
GenerateChunk((activeChunkPosition.x + 1), activeChunkPosition.y, activeChunkPosition.z); | |
try { | |
//Clean up chunks behind us. | |
DeleteChunk (Chunks[new Vector3(activeChunkPosition.x - 2, activeChunkPosition.y, activeChunkPosition.z)]); | |
} | |
catch { | |
Debug.Log ("Just tried to delete a chunk, but we havent made it yet!"); | |
} | |
// Set the ActiveChunk to the newly generated one. | |
ActiveChunk = Chunks[new Vector3((activeChunkPosition.x + 1), activeChunkPosition.y, activeChunkPosition.z)]; | |
} | |
if (Ship.transform.position.y > (activeChunkPosition.y * ChunkSize) + ChunkSize/4) { | |
GenerateChunk(activeChunkPosition.x, (activeChunkPosition.y + 1), activeChunkPosition.z); | |
try { | |
DeleteChunk (Chunks[new Vector3(activeChunkPosition.x, activeChunkPosition.y - 2, activeChunkPosition.z)]);} | |
catch { | |
Debug.Log ("Just tried to delete a chunk, but we havent made it yet!"); | |
} | |
// Set the ActiveChunk to the newly generated one. | |
ActiveChunk = Chunks[new Vector3(activeChunkPosition.x, activeChunkPosition.y + 1, activeChunkPosition.z)]; | |
} | |
if (Ship.transform.position.z > (activeChunkPosition.z * ChunkSize) + ChunkSize/4) { | |
GenerateChunk(activeChunkPosition.x, activeChunkPosition.y, (activeChunkPosition.z + 1)); | |
try { | |
DeleteChunk (Chunks[new Vector3(activeChunkPosition.x, activeChunkPosition.y, activeChunkPosition.z - 2)]);} | |
catch { | |
Debug.Log ("Just tried to delete a chunk, but we havent made it yet!"); | |
} | |
// Set the ActiveChunk to the newly generated one. | |
ActiveChunk = Chunks[new Vector3(activeChunkPosition.x, activeChunkPosition.y, activeChunkPosition.z + 1)]; | |
} | |
//// NEGATIVE MOVEMENT | |
/// ---------------------------------------------------------------------------------------------------------------------- | |
if (Ship.transform.position.x < (activeChunkPosition.x * ChunkSize) - ChunkSize/4) { | |
// Make a new chunk in the direction we're going. | |
GenerateChunk((activeChunkPosition.x - 1), activeChunkPosition.y, activeChunkPosition.z); | |
try { | |
//Clean up chunks behind us. | |
DeleteChunk (Chunks[new Vector3(activeChunkPosition.x + 2, activeChunkPosition.y, activeChunkPosition.z)]); | |
} | |
catch { | |
Debug.Log ("Just tried to delete a chunk, but we havent made it yet!"); | |
} | |
// Set the ActiveChunk to the newly generated one. | |
ActiveChunk = Chunks[new Vector3((activeChunkPosition.x - 1), activeChunkPosition.y, activeChunkPosition.z)]; | |
Debug.Log(ActiveChunk.transform.position); | |
} | |
if (Ship.transform.position.y <(activeChunkPosition.y * ChunkSize) - ChunkSize/4) { | |
GenerateChunk(activeChunkPosition.x, (activeChunkPosition.y - 1), activeChunkPosition.z); | |
try { | |
DeleteChunk (Chunks[new Vector3(activeChunkPosition.x, activeChunkPosition.y + 2, activeChunkPosition.z)]);} | |
catch { | |
Debug.Log ("Just tried to delete a chunk, but we havent made it yet!"); | |
} | |
// Set the ActiveChunk to the newly generated one. | |
ActiveChunk = Chunks[new Vector3(activeChunkPosition.x, activeChunkPosition.y - 1, activeChunkPosition.z)]; | |
} | |
if (Ship.transform.position.z < (activeChunkPosition.z * ChunkSize) - ChunkSize/4) { | |
GenerateChunk(activeChunkPosition.x, activeChunkPosition.y, (activeChunkPosition.z - 1)); | |
try { | |
DeleteChunk (Chunks[new Vector3(activeChunkPosition.x, activeChunkPosition.y, activeChunkPosition.z + 2)]);} | |
catch { | |
Debug.Log ("Just tried to delete a chunk, but we havent made it yet!"); | |
} | |
// Set the ActiveChunk to the newly generated one. | |
ActiveChunk = Chunks[new Vector3(activeChunkPosition.x, activeChunkPosition.y, activeChunkPosition.z - 1)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment