Quantcast
Channel: Latest Questions by ARexx_808
Viewing all articles
Browse latest Browse all 4

How to implement a flip direction to my 2D character controller?

$
0
0
I am new to C# programming and I have my character controller script here, but how can I make the sprite flip direction when controlling it? This is what I have so far. public class CharacterController : MonoBehaviour { public float speed = 1.0f; public string axisHorizontal = "Horizontal"; public string axisVertical = "Vertical"; public Animator anim; // Use this for initialization void Start () { anim = gameObject.GetComponent (); } // Update is called once per frame void Update () { anim.SetFloat("Speed", Mathf.Abs(Input.GetAxis(axisHorizontal))); anim.SetFloat("Speed", Mathf.Abs(Input.GetAxis(axisVertical))); transform.position += transform.right *Input.GetAxis(axisHorizontal)* speed * Time.deltaTime; transform.position += transform.up *Input.GetAxis(axisVertical)* speed * Time.deltaTime; } }

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>