Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question How to scale a 2d sprite on its z axis?

Discussion in '2D' started by Geniusme56, Jun 4, 2023.

  1. Geniusme56

    Geniusme56

    Joined:
    Aug 21, 2021
    Posts:
    55
    I am trying to make a 2d game, with some 2.5 game objects. As the camera moves, i want you to see different parts of an object. Sort of like this.
    How would I achieve this? I tried putting my sprite on a object as a material, but it shows the front on all the side. How would I fix this?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,947
    This effect is called parallax.

    Two ways:

    - switch to a perspective camera

    - stay with an ortho camera and simulate the parallax yourself

    Google for more.
     
  3. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    those are 3d objects, sorry to say you will need 3d models
     
    karliss_coldwild and Kurt-Dekker like this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,947
    @karderos oh I just noticed that... you're probably right!!

    But I suppose if you were really really really determined you could make a "house of cards" level out of all kinds of little 2D sprites tilted to different angles and placed at different depths!!

    So OP: yeah, you "gotta" use 3D to make 3D games, modulo doing some trickery with sprites above.

    Here was my 2.5D proof-of-concept mover: feel free to look around and tear it apart.



    Full project at:

    proximity_buttons is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/proximity_buttons

    https://github.com/kurtdekker/proximity_buttons

    https://gitlab.com/kurtdekker/proximity_buttons

    https://sourceforge.net/projects/proximity-buttons/
     
  5. Geniusme56

    Geniusme56

    Joined:
    Aug 21, 2021
    Posts:
    55
    Thanks! I will check it out. What i will probably do is put the same sprite behind it.