From 41203be8dc0d9825099d9eaf19382018ca7c6dd7 Mon Sep 17 00:00:00 2001 From: LeeJaeHyun Date: Wed, 11 Sep 2024 15:37:19 +0900 Subject: [PATCH] . --- Assets/01_Scenes/GameLogic.unity | 1 + Assets/02_Scripts/PlayerController.cs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Assets/01_Scenes/GameLogic.unity b/Assets/01_Scenes/GameLogic.unity index 69d273c..d4eb195 100644 --- a/Assets/01_Scenes/GameLogic.unity +++ b/Assets/01_Scenes/GameLogic.unity @@ -809,6 +809,7 @@ MonoBehaviour: m_EditorClassIdentifier: moveSpeed: 8 turnSpeed: 200 + animator: {fileID: 0} --- !u!1001 &1157015548 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/02_Scripts/PlayerController.cs b/Assets/02_Scripts/PlayerController.cs index b7afe1c..289f95a 100644 --- a/Assets/02_Scripts/PlayerController.cs +++ b/Assets/02_Scripts/PlayerController.cs @@ -15,10 +15,23 @@ public class PlayerController : MonoBehaviour void Start() { - + // 컴포넌트 추출 및 할당 + animator = this.gameObject.GetComponent(); } void Update() + { + Move(); + PlayerAnimation(); + } + + private void PlayerAnimation() + { + animator.SetFloat("Forward", v); + animator.SetFloat("Strafe", h); + } + + private void Move() { h = Input.GetAxis("Horizontal"); // 1차원 연속값 -1.0 ~ 0.0 ~ +1.0 v = Input.GetAxis("Vertical"); // -1.0f ~ 0.0f ~ +1.0f