x


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?

more ▼

asked Mar 26 '11 at 07:44 PM

AtomicMarine gravatar image

AtomicMarine
504 42 49 70

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
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!

more ▼

answered Mar 26 '11 at 09:08 PM

Justin Warner gravatar image

Justin Warner
6.3k 19 27 65

Oh, and to change the speed, change Time.deltaTime.

Mar 26 '11 at 09:08 PM Justin Warner
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5070
x2994
x1034
x89

asked: Mar 26 '11 at 07:44 PM

Seen: 1521 times

Last Updated: Mar 26 '11 at 10:41 PM