Answer the question
In order to leave comments, you need to log in
I can not understand how to reflect the character in unity?
There is a control implemented through Vector2, It is necessary to reflect the character when moving (but this is not necessary when moving up (looks awful))
private Vector2 moveVelocity;
void Start()
{
rb=GetComponent<Rigidbody2D>();
}
void Update()
{
Vector2 moveInput = new Vector2(Input.GetAxisRaw("Horizontal"),Input.GetAxisRaw("Vertical"));
moveVelocity=moveInput.normalized*speed;
}
void flip()
{
faceRight=!faceRight;
transform.localScale= new Vector3(transform.localScale.x*-1,transform.localScale.y,transform.localScale.x);
}
void FixedUpdate()
{
rb.MovePosition(rb.position+moveVelocity*Time.fixedDeltaTime);
}
}
Answer the question
In order to leave comments, you need to log in
It is possible through SpriteRenderer.flipX. Moving on x < 0 - moving to the left and flipX = true,
Moving on x > 0 - moving to the right and flipX = false
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question