How to move and flip a 2D character with scripting (C#) in Unity 2018, using the left and right arrows keys to move the player. Unity beginner tutorial.

● Download the free Sunny Land 2D assets here:
https://assetstore.unity.com/packages/2d/characters/sunny-land-103349
(Affiliate link / sponsored by Unity)

● Other free packages at the Unity Assets Store:
https://assetstore.unity.com/lists/top-free-packages-13201

● Character script:


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour {

    void Update () {

        // Move the Character:
        transform.Translate(Input.GetAxis("Horizontal") * 15f * Time.deltaTime, 0f, 0f);

        // Flip the Character:
        Vector3 CharacterScale = transform.localScale;
        if (Input.GetAxis("Horizontal") < 0) {
            CharacterScale.x = -10;
        }
        if (Input.GetAxis("Horizontal") > 0)
        {
            CharacterScale.x = 10;
        }
        transform.localScale = CharacterScale;

    }
}