์ผ€์ด๋“œ ์ฏ”๊พธ๋ฅด ๊ฐ•์˜ ๋“ฃ๊ณ  ์žˆ๋Š”๋ฐ


using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UIElements; public class MovingObject : MonoBehaviour { public float speed; private Vector3 vector; public float runSpeed; private float applyRunSpeed; private bool applyRunFlag = false; public int walkCount; private int currentWalkCount; private bool canMove = true; private void Start() { } IEnumerator MoveCorutine() { vector.Set(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), transform.position.z); if (Input.GetKey(KeyCode.LeftShift)) { applyRunSpeed = runSpeed; } else { applyRunSpeed = 0; applyRunFlag = true; } while (currentWalkCount < walkCount) { if (vector.x != 0) { transform.Translate(vector.x * (speed + applyRunSpeed), 0, 0); } else if (vector.y != 0) { transform.Translate(0, vector.y * (speed + applyRunSpeed), 0); } if (applyRunFlag) { currentWalkCount++; } currentWalkCount++; yield return new WaitForSeconds(0.01f); } currentWalkCount = 0; canMove = true; } private void Update() { if (canMove) { if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) { canMove = false; StartCoroutine(MoveCorutine()); } } } } ์ด์ฝ”๋“œ์—์„œ ๊ฒฐ๊ตญ์—๋Š” leftshift๋ฅผ ๋ˆ„๋ฅด๋ฉด while (currentWalkCount < walkCount)์ด๊ฒŒ 10๋ฒˆ ๋ˆ„๋ฅด์ง€ ์•Š์œผ๋ฉด 20๋ฒˆ ์‹คํ–‰๋˜๋Š”๋ฐ speed๊ฐ’๊ณ  applyRunSpeed ๊ฐ’์ด 2.4๋กœ ๋™์ผํ•˜๋‹ˆ leftshift๋ฅผ ๋ˆŒ๋ €์„๋•Œ๋‚˜ ์•ˆ๋ˆŒ๋ €์„๋•Œ๋‚˜ 48๋กœ ์†๋„๊ฐ€ ๋˜‘๊ฐ™์ง€ ์•Š๋‚˜์š”? ๊ทธ๋Ÿฐ๋ฐ ์™œ ์œ ๋‹ˆํ‹ฐ ์ƒ์—์„œ๋Š” leftshift๋ฅผ ๋ˆ„๋ฅธ๊ฒŒ ๋” ๋น ๋ฅด๊ฒŒ ๋‚˜์˜ฌ๊นŒ์š”?