- Home /
Question by
AtomicMarine · Mar 26, 2011 at 07:44 PM ·
camera2dorthographic
Backgrounds moving at different speeds?
How would I make 2-3 background planes (with textures for the backgrounds) move at different speeds as the player moves through the level to give a more lively feel to the game?
Like hills move slower then buildings in front of the hills all an orographic camera with 2d images?
Comment
Best Answer
Answer by Justin Warner · Mar 26, 2011 at 09:08 PM
function Update() {
// Move the object to the right relative to the camera 1 unit/second.
transform.Translate(Vector3.right * Time.deltaTime, Camera.main.transform);
}
http://unity3d.com/support/documentation/ScriptReference/Transform.Translate.html
That moves the the objects (Background or w/e to the camera, should work well for a 2D game, might need to change Vector3.right to Vector3.up or Vector3.forward.
Good luck!
Oh, and to change the speed, change Time.deltaTime.