From 98597d1053c59232eec6d5d7493212b36aa6012a Mon Sep 17 00:00:00 2001 From: Mingu Kim Date: Thu, 5 Jun 2025 03:21:27 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BA=90=EB=A6=AD=ED=84=B0=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99=20=EC=BD=94=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Movement2D.cs | 14 ++++++++++++++ Assets/Scripts/Movement2D.cs.meta | 2 ++ Assets/Scripts/PlayerController.cs | 19 +++++++++++++++++++ Assets/Scripts/PlayerController.cs.meta | 2 ++ 4 files changed, 37 insertions(+) create mode 100644 Assets/Scripts/Movement2D.cs create mode 100644 Assets/Scripts/Movement2D.cs.meta create mode 100644 Assets/Scripts/PlayerController.cs create mode 100644 Assets/Scripts/PlayerController.cs.meta diff --git a/Assets/Scripts/Movement2D.cs b/Assets/Scripts/Movement2D.cs new file mode 100644 index 00000000..31ecdd95 --- /dev/null +++ b/Assets/Scripts/Movement2D.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +public class Movement2D : MonoBehaviour +{ + [SerializeField] + private float moveSpeed = 5f; + + public Vector3 MoveDirection { get; set; } = Vector2.zero; + + private void Update() + { + transform.position += MoveDirection * moveSpeed * Time.deltaTime; + } +} diff --git a/Assets/Scripts/Movement2D.cs.meta b/Assets/Scripts/Movement2D.cs.meta new file mode 100644 index 00000000..510fdb63 --- /dev/null +++ b/Assets/Scripts/Movement2D.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0ea3e7753e5fb28479a6f577e4b35668 \ No newline at end of file diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs new file mode 100644 index 00000000..b5cf6d39 --- /dev/null +++ b/Assets/Scripts/PlayerController.cs @@ -0,0 +1,19 @@ +using UnityEngine; + +public class PlayerController : MonoBehaviour +{ + private Movement2D movement2D; + + private void Awake() + { + movement2D = GetComponent(); + } + + private void Update() + { + float x = Input.GetAxis("Horizontal"); + float y = Input.GetAxis("Vertical"); + + movement2D.MoveDirection = new Vector2(x, y); + } +} diff --git a/Assets/Scripts/PlayerController.cs.meta b/Assets/Scripts/PlayerController.cs.meta new file mode 100644 index 00000000..55fb6b41 --- /dev/null +++ b/Assets/Scripts/PlayerController.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 7faac9c66ceb4b342b90f97ea09a456c \ No newline at end of file