Search Unity

Script to make an object always face the camera?

Discussion in 'Scripting' started by GoreBacke, Jul 1, 2009.

  1. GoreBacke

    GoreBacke

    Joined:
    Jun 30, 2009
    Posts:
    11
    I'm making a game witch uses 2d sprites on a 3d environment. I have the sprite as a texture on a plane and I have the plane rotated 90 degrees on the x axis. How would I go about making a script so the z axis changes to always face the camera. Also is it possible to change textures on an object with scripts?
     
  2. Lokken

    Lokken

    Joined:
    Apr 23, 2009
    Posts:
    436
  3. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    There's a script in the Wiki for doing this:

    [link removed, it is now updated]

    You can probably just set the Z axis to be the only one that changes and that should work.

     
    Last edited by a moderator: Jan 30, 2021
  4. GingerSnaps84

    GingerSnaps84

    Joined:
    Jul 10, 2012
    Posts:
    3
    Thanks for posting this, I'm new to the forums and this helped me out a great bit
     
  5. Partomo

    Partomo

    Joined:
    Oct 7, 2013
    Posts:
    17
    It seems that the link is broken?
     
  6. ittytheitstar

    ittytheitstar

    Joined:
    Nov 13, 2014
    Posts:
    1
  7. OldBen1

    OldBen1

    Joined:
    Apr 3, 2020
    Posts:
    4
    New link?
     
  8. esgnn

    esgnn

    Joined:
    Mar 3, 2020
    Posts:
    38