Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 입출력
- db
- Stack
- 동기화블럭
- cocos2d-x
- 게임엔진
- c++
- cocos2dx
- 데이터타입
- interface상속
- 스레드
- c++게임엔진
- unity
- Thread
- C/C++
- oracle
- cocos2d
- Interface
- 프로그래밍
- 문자열
- Exception
- 예외던지기
- singleton
- 예외처리
- 데이터베이스
- Class함수
- 반복문
- java
- 상수변수
- c#
Archives
- Today
- Total
초보 프로그램 개발자
[Unity] 선형보간 Lerp 본문
선형보간이란?
두 점이 주어졌을 때, 그 사이의 위치를 모르는 값을 추정하기 위하여 직선 거리에 따라 선형적으로 계산하는 방법
유니티에서의 사용방법
Mathf.Lerp(); // 두 점 사이의 선형보간
Vector2.Lerp(); // Vector2 사이의 선형보간
Vector3.Lerp(); // Vector3 사이의 선형보간
Quaternion.Lerp(); // Quaternion 사이의 선형보간
Lerp() 함수 사용 예시
float x = Mathf.Lerp(0, 10, 0.5f);
Vector2 pos = Vector2.Lerp(Vector2.zero, new Vector2(10, 10), 0.3f);
위와 같이 사용한다고 하였을때 x 는 5가 나올것이고 pos 는 (3.3) 이 나올것이다.
이처럼 마지막 파라미터에 연관되어 값이 나오므로 계속해서 변화하는 Time.deltaTime 이나 다른 수치를 넣어주어
부드러운 이동 또는 이미지의 a값 등등 유용하게 쓰일수 있다.
유니티 공식 문서
https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html
Unity - Scripting API: Vector3.Lerp
Interpolates between the points a and b by the interpolant t. The parameter t is clamped to the range [0, 1]. This is most commonly used to find a point some fraction of the way along a line between two endpoints (e.g. to move an object gradually between t
docs.unity3d.com
'Unity' 카테고리의 다른 글
[Unity] 곡선 이동 (베지어곡선) (0) | 2023.01.10 |
---|---|
[Unity] 오브젝트 재활용 (0) | 2023.01.10 |
[Unity] Bullet 스크립트 정리 (0) | 2022.12.08 |
[Unity] 싱글톤 패턴 (0) | 2022.12.08 |
[Unity] Collider2D 정리 (0) | 2022.12.07 |