Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

rotate player unity

//Rotate player 2D Left and Right
static Vector3 EscalaOriginal;

static Vector3 NovaEscala;

void Start(){

 EscalaOriginal = gameobject.transform.localScale;
 NovaEscala = new Vector3(-0.5f, EscalaOriginal.y, EscalaOriginal.z);
}

 void FixedUpdate()
    {
        //float horizontal = Input.GetAxis("Horizontal");

        //HandleMovement (horizontal); //Movement

        if (gameobject.transform.localScale != NovaEscala)
        {
            if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
            {
                gameobject.transform.localScale = NovaEscala;
            }
        }

        if (gameobject.transform.localScale != EscalaOriginal)
        {
            if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
            {
                gameobject.transform.localScale = EscalaOriginal;
            }
        }
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# windows forms print 
Csharp :: Unity Destroy gameObject upon collision 
Csharp :: vscode not showing errors c# 
Csharp :: unity event 
Csharp :: get folder path winforms 
Csharp :: how to put double quotes in a string c# 
Csharp :: c# print list 
Csharp :: .net get system environment variable 
Csharp :: wpf button 
Csharp :: godot c# export variables 
Csharp :: unity how to set rigidbody velocity 
Csharp :: c# create dynamic json 
Csharp :: c# Get type with namespace 
Csharp :: unity call function on animation onstateexit 
Csharp :: how to add item in list at first position c# 
Csharp :: csharp datagridview filter column 
Csharp :: generate entity model dot net core 
Csharp :: rock paper scissors c# 
Csharp :: how to get specific length of row in matrix c# 
Csharp :: how to set a transform equal to something unity 
Csharp :: get text after word C# 
Csharp :: c# insert spaces before capital letters 
Csharp :: how to remove white spaces from string in c# 
Csharp :: how to make button in asp.net to go to other page 
Csharp :: how to flip a character in unity 2d 
Csharp :: get processor id c# web application 
Csharp :: how to get previous page url aspnet core 
Csharp :: bundle.config in mvc is missing 
Csharp :: how to chceck for a tag in a trigger enter 2d unity 
Csharp :: test how catch exception c# 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =