soso03185
@soso031850289
Reviews Written
2
Average Rating
5.0
Posts
Q&A
_destPos๊ฐ ๊ณ์ 0์ธ ์ํ์ ๋๋ค.
ํ.. ๊ฐ์ฌํฉ๋๋ค
- 0
- 4
- 481
Q&A
_destPos๊ฐ ๊ณ์ 0์ธ ์ํ์ ๋๋ค.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class MonsterController : BaseController { Stat _stat; [SerializeField] float _scanRange = 10f; [SerializeField] float _attackRange = 2; public override void Init() { _stat = gameObject.GetComponent(); if (gameObject.GetComponentInChildren() == null) Managers.UI.MakeWorldSpaceUI(transform); } protected override void UpdateIdle() { Debug.Log("Monster UpdateIdle"); GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player == null) return; float distance = (player.transform.position - transform.position).magnitude; if(distance { _lockTarget = player; State = Define.State.Moving; return; } } protected override void UpdateMoving() { //ํ๋ ์ด์ด๊ฐ ๋ด ์ฌ์ ๊ฑฐ๋ฆฌ๋ณด๋ค ๊ฐ๊น์ฐ๋ฉด ๊ณต๊ฒฉ if (_lockTarget != null) { float distance = (_destPos - transform.position).magnitude; if (distance { State = Define.State.Skill; return; } } //์ด๋ Vector3 dir = _destPos - transform.position; if (dir.magnitude { State = Define.State.Idle; } else { NavMeshAgent nma = gameObject.GetOrAddComponent(); nma.SetDestination(_destPos); nma.speed = _stat.MoveSpeed; transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(dir), 20 * Time.deltaTime); } } protected override void UpdateSkill() { Debug.Log("Monster UpdateSkill"); } void OnHitEvent() { Debug.Log("Monster OnHitEvent"); } }
- 0
- 4
- 481
Q&A
๊ถ๊ธํ ์ ์ด ์์ด์ ์ฌ์ญค๋ด ๋๋ค!
๊ฐ์ฌํฉ๋๋ค!
- 0
- 2
- 241
Q&A
๊ณต๊ฒฉ ํ์ ์ด ์ ์๋ฉ๋๋ค
๋๋ฒ๊น ์์๊น์ง ์ฐ์ด์ฃผ์๊ณ ์ ๋ง ๊ฐ์ฌํฉ๋๋ค. ๋๋ถ์ ์ ํด๊ฒฐ๋์์ด์!
- 1
- 5
- 601




