Skip to content

260309#10

Open
uri0921-ctrl wants to merge 13 commits into
mainfrom
yuri
Open

260309#10
uri0921-ctrl wants to merge 13 commits into
mainfrom
yuri

Conversation

@uri0921-ctrl

Copy link
Copy Markdown
Collaborator

배운 점

  1. 캐릭터 구현
  2. 캐릭터 움직임 / 피해 구현
  3. PR close

개선할 점

  1. 파일 삭제를 했지만, commit 기록이 깔끔하지 않음. (개선법 찾기.)
  2. 코드 엔진 작동 이해 / 오류 확인

@psvm203 psvm203 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

유리님 스터디 진행하시느라 고생하셨어요!

커밋이 2번씩 있는 건 메인 브랜치에 잘못 푸시하셨을 때 제가 변경사항을 옮기느라 생긴거예요.

git rebase를 사용하면 커밋 기록을 수정할 수도 있지만, 히스토리가 망가질 수도 있으니 웬만하면 남겨두는 걸 추천해요.

앞으로 유니티 혹은 다른 게임 엔진이더라도 궁금한 점 있으면 저에게 DM 주세요!


private void OnTriggerStay2D(Collider2D other)
{
if (other.CompareTag("Player")) other.GetComponent<FarmerHp>().TakeDamage(Damage);

@psvm203 psvm203 Mar 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가이드에서 알려드리지는 않았지만, 업데이트나 충돌 체크등 반복되는 작업에서 GetComponent를 실행하면 시간이 오래 걸립니다.
다음에 프로젝트를 할 때에는 최대한 회피할 수 있는 방법을 찾아보시면 좋을거예요.
또한, 같은 상황이라면 TryGetComponent를 쓰시면 더 좋아요.

Comment on lines +16 to +17
direction.Normalize();
transform.Translate(Time.deltaTime * Speed * direction);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normalize를 하는 이유는 무엇일까요?
Time.deltaTime을 곱하지 않으면 어떤 경우에 문제가 발생할까요?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.대각선 이동 속도가 상대적으로 빨라지기에, 정규화를 하여 직선 방향 이동과 대각선 방향 이동 속도를 맞추는 것입니다.
2. 프레임 속도에 따라 거리 이동이 달라지기에, 초당 프레임 120으로 바꾸었을 때 이동 거리가 2배가 되는 문제가 생길 것입니다.

private void OnMove(InputValue value)
{
_moveDirection = value.Get<Vector2>();
_moveDirection.Normalize();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normalize를 하지 않으면 어떤 상황에서 문제가 발생할까요?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

대각선으로 움직일 때 이동 속도가 더 빨라지게 됩니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants