Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Moving 2D terrain - transform or physics?

Discussion in 'Scripting' started by DannyB, Feb 12, 2014.

  1. DannyB

    DannyB

    Joined:
    Jun 20, 2012
    Posts:
    214
    Hey everybody,

    Hope someone can point me in the right direction here, this is the situation:

    I would like to move a 2D terrain (sprites) in front of the camera. This terrain is built of chunks, and naturally, each with its own collider.

    Currently, the way I built it is that I have a container object holding all the chunks, and I am moving the container by its transform.
    Now, it does work pretty well and as expected, but I cant shake the feeling that I am doing something wrong.

    Should I move it with rigidbody.AddForce?

    And if so, a couple of questions arise:
    1. The container itself is a simple object, without any rigidbody. Should I add one to it? Or should I move each of the terrain chunks separately?
    2. I want this terrain to keep on moving at a completely constant speed (think scrolling game) and not be influenced by collissions or other physics properties. Possible.

    Or maybe I should keep moving by transorm, and just do it in FixedUpdate()?

    Thanks in advance.