게시글
고민있어요
2021.06.28 16:35
메모: BaseController 작성
- 0
- 0
- 207
질문&답변
2021.06.05
_destPos가 계속 0인 상태입니다.
헐.. 감사합니다
- 0
- 4
- 381
질문&답변
2021.06.03
_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
- 381
질문&답변
2021.06.02
궁금한 점이 있어서 여쭤봅니다!
감사합니다!
- 0
- 2
- 189
질문&답변
2021.05.26
공격 판정이 잘 안됩니다
디버깅영상까지 찍어주시고 정말 감사합니다. 덕분에 잘 해결되었어요!
- 1
- 5
- 480