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

(Solved + Script) MIRRORING 2D ACTION IN 3D(2.5D)

Discussion in 'Scripting' started by frozendog_bren, Jun 29, 2015.

  1. frozendog_bren

    frozendog_bren

    Joined:
    Nov 29, 2014
    Posts:
    19
    What's up, mates. Right to the point.

    I'm creating a 3D platformer, but having some problems with that "mirroring" stuff we have in Construct 2 or maybe in Unity 2D (Never tried that).

    Basically what i want to do is:

    - When my input horizontal is greater than 0, my cube turns to left (or the side it should be) and when less than 0 it turns to the other side. But here's the problem: I need this to keep facing to the side it turned to.

    THANKS

    -----x-----
    SOLUTION:

    -It started to work properly when i used GetAxisRaw, instead of GetAxis. F*ck me, right?

    Code (CSharp):
    1.         if(Input.GetAxisRaw("Horizontal") > 0f)
    2.         {
    3.             transform.rotation=Quaternion.Euler(0f,270,0f);
    4.         }
    5.         if(Input.GetAxisRaw("Horizontal") < 0f)
    6.         {
    7.             transform.rotation=Quaternion.Euler(0f,90,0f);
    8.         }
    9.  
     
    Last edited: Jun 29, 2015
  2. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    For next time: asking directly for code is frowned upon by most forum users. Try making the relevant code yourself first, then post your code here if you can't get it to work. What you are asking for is basic unity stuff and is covered in the tutorials.
     
  3. frozendog_bren

    frozendog_bren

    Joined:
    Nov 29, 2014
    Posts:
    19
    Alright, thanks.