
x와 z값이 출력된다.

moveDir와 new Vector3(h,0,v)는 같은 값을 출력하지만
moveDir는 연산을 해준 것을 변수에 담은 것이고, 후자는 벡터에 넣어 찍어본 것이다.
즉 전자는 두 벡터를 더하는 연산으로 이는 새로운 벡터가 생겨나는 것인데,
새로운 벡터에 값을 넣어주는 것과 같은 의미가 되는 것이다.
화살표를 화면에 그려서 비교해보려 한다.
https://gist.github.com/MatthewMaker/5293052
DrawArrow.cs
GitHub Gist: instantly share code, notes, and snippets.
gist.github.com

https://docs.unity3d.com/ScriptReference/Vector3-normalized.html
Unity - Scripting API: Vector3.normalized
When normalized, a vector keeps the same direction but its length is 1.0. Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use Normalize function. If the vector is too small to
docs.unity3d.com




Vector3.normalized를 하면 정규화된 벡터를 반환한다.
=> normalized를 이용하면 대각선으로 이동할 때에도 동일한 속도를 보장할 수 있다.




'유니티 심화' 카테고리의 다른 글
파티클 활용, 폭발, random texture,폭발력 적용(AddExplosionForce) (0) | 2023.08.21 |
---|---|
총 발사, 총알 발사 궤적 효과 만들기 - Trail Renderer (0) | 2023.08.18 |
카메라 이동 연습 2(draw gizmos, 선형 보간과 구면 선형 보간) (0) | 2023.08.18 |
카메라 위치 조정 & Zoom In/Out (0) | 2023.08.17 |
플레이어 이동 구현(키보드, 조이스틱) (0) | 2023.08.17 |