- 피봇이 하단에 있어야 씬 모드에서 오브젝트 배치할때 편함.
- 큐브의 피봇은 오브젝트의 센터에 있어서 씬에 배치할때 아래쪽이 잠기는 현상이 발생.
목표를 고정 타게팅할때 메쉬렌더러를 체크하고, 있으면
aim.position = target.GetComponent<Renderer>().bounds.center;
코드를 적용해서 메쉬렌더러의 정중앙으로 Aim(목표)을 고정시킴.
이 코드 없이 그냥 Aim을 target.position으로 하면, 피봇이 오브젝트의 바닥에 있어서 중앙이 아니라 오브젝트의 바닥을 목표로 공격함.
private void UpdateAimPosition()
{
Transform target = Target();
if( target != null && isLockingToTarget )
{
if(target.GetComponent<Renderer>() != null)
{
aim.position = target.GetComponent<Renderer>().bounds.center;
}
else
{
aim.position = target.position;
}
return;
}
aim.position = GetMouseHitInfo().point;
if (!isAimingPrecisely)
{
aim.position = new Vector3(aim.position.x, transform.position.y + 1, aim.position.z);
}
//aim.position = new Vector3(GetMousePosition().x, transform.position.y + 1, GetMousePosition().z);
}
유니티 포스트프로세싱 블룸 (0) | 2024.10.15 |
---|---|
유니티 오브젝트에 레이어 이름 추가하기(스크립트로 추가) (0) | 2024.10.15 |
유니티 마우스 타겟 고정 하기 (0) | 2024.10.12 |
유니티 탑다운 게임 개발 Version.1 (1) | 2024.10.10 |
유니티 애니메이터 레이어(Animator layer) 껐다 키기 (1) | 2024.10.08 |