- Home /
Duplicate everything in a set space in all directions?
So imagine the player is a ball and the controls are only left and right, which applies torque to the ball in either direction. The player is on a plane and there is a mirror version of him on the other side of the plane that does the opposite of whatever he does.
The player can't leave the bounds of this plane because of the environment, but what I'm trying to do is basically rerender or duplicate everything within that plane a bunch of times in all directions. Once the player solves the puzzle, the camera will pan to a 90 degree angle towards all of the planes and zoom out to reveal a sort of wallpaper, which is part of the next environment.
I hope I don't sound crazy. I can think of dirty ways to do this, but I was wondering if there's anything interesting I could do to make this happen in a cleanly way?
Answer by Cameron 2 · Jun 05, 2010 at 10:47 AM
Here's what I wrote.
Having a ton of objects moving that rely on the location of other objects is processor intensive, so I'm going to have a different prefab that has no moving elements farther out. For now:
Things are multiplied by 20 because that's how big the prefab is.
var prefab : Transform;
function Start () { for (var i=1;i<5;i++) { Instantiate (prefab, Vector3(i 20.0, 0, 0), Quaternion.identity); Instantiate (prefab, Vector3(-i 20.0, 0, 0), Quaternion.identity); Instantiate (prefab, Vector3(0, 0, i * 20), Quaternion.identity);
for (var x=1;x<5;x++) {
Instantiate (prefab, Vector3(x * 20.0, 0, i * 20), Quaternion.identity);
Instantiate (prefab, Vector3(-x * 20.0, 0, i * 20), Quaternion.identity);
}
}
}
Each slave of the player uses the following script. It isn't very good with the CPU, so I'm going to try to find a better way to do it.
var offset;
function Start() { var master = GameObject.Find("Player"); offset = master.transform.position - transform.position; }
function Update () { var master = GameObject.Find("Player"); transform.position = master.transform.position - offset; transform.rotation = master.transform.rotation; }
Answer by Adrian Love · Jun 03, 2010 at 06:03 AM
You have two options, pretty much render an image of the scene and apply it to a block so when you zoom out far enough the player can't tell the difference or, leave it there and replace everything with low-poly/low-res once they zoom out.
As for copying, Store all of your GameObjects in a Prefab and replicate it using scripting, would be my guess...
I'm new to unity so these ideas are pretty conceptual.
Thanks for the suggestions.
I think I'm going to try to have a master prefab and then a bunch of slave prefabs. The gravity and everything takes place in the master prefab, and the other ones just translate all of the objects in relation to the master.
Sounds like it's crazy enough to work, let us know when you finish it, it'd be interesting to see what sorts of things you can come up with.