Created
August 22, 2021 05:19
-
-
Save foxqstm/9a6b60bb65845f73810a95a016c39b0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class PlayerController : MonoBehaviour | |
{ | |
public int speed = 1; | |
float sc = 0.3162f; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
int key = 0; | |
if(Input.GetKeyDown(KeyCode.LeftArrow)) | |
{ | |
transform.Translate(-speed, 0, 0); | |
key = 1; | |
} | |
if (Input.GetKeyDown(KeyCode.RightArrow)) | |
{ | |
transform.Translate(speed, 0, 0); | |
key = -1; | |
} | |
if (key != 0) | |
{ | |
transform.localScale = new Vector3(sc * key, sc, sc); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment