Question by
Applefruits · Apr 21, 2016 at 02:42 PM ·
rotationsprite2d game2d-platformer2d-gameplay
2D Sprite rotation 180 degrees
Hello , I'm making a 2D game and I got my character moving. But when I want to make the sprite face the direction I'm walking. I can't seem to figure out how to do that with with Input.getaxis
using UnityEngine;
using System.Collections;
public class PlayerController2D : MonoBehaviour {
[SerializeField]
private float speed = 5f;
private PlayerMotor2D motor2D;
// Use this for initialization
void Start ()
{
motor2D = GetComponent<PlayerMotor2D>();
}
// Update is called once per frame
void Update ()
{
float _xMov = Input.GetAxisRaw("Horizontal");
Vector2 _movHorizontal = transform.right * _xMov;
Vector2 _velocity = (_movHorizontal).normalized * speed;
motor2D.Move(_velocity);
}
}
Thanks in advanced.
Comment
Your answer
Follow this Question
Related Questions
How Do I Lock The Y Axis In A Camera Follow Script? 1 Answer
Ragdoll Movement Script, Help! 0 Answers
How to make a functioning lantern in 2D 0 Answers
How Do I stop AI Following player on the Y-axis? 0 Answers
2d platformer physics 0 Answers