Created
February 15, 2021 19:25
-
-
Save doyle-flutter/dbe4aed12c027436d592d688da37aa00 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 UserContoller : MonoBehaviour | |
| { | |
| private Vector3 vector; | |
| public float speed = 0.5F; | |
| // 버튼용 | |
| GameObject user; | |
| void Start() | |
| { | |
| // 버튼용 | |
| user = GameObject.Find("User"); | |
| } | |
| void Update() | |
| { | |
| vector.Set(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0); | |
| if(vector.x != 0 || vector.y != 0){ | |
| transform.Translate(vector.x * speed, vector.y * speed, 0); | |
| } | |
| } | |
| public void LeftMove(){ | |
| user.transform.Translate(-1.0F * speed, 0, 0); | |
| } | |
| public void RightMove(){ | |
| user.transform.Translate(1.0F * speed, 0, 0); | |
| } | |
| public void UpMove(){ | |
| user.transform.Translate(0, 1.0F * speed, 0); | |
| } | |
| public void DownMove(){ | |
| user.transform.Translate(0, -1.0F * speed, 0); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment