'잡다한것들전부/공식예제'에 해당되는 글 13건
- 2014.02.25 주인공을 따라다니는 카메라
- 2014.02.25 플레이어 컨트롤 스크립트
- 2014.02.25 배경 시차 스크롤 카메라의 움직임에따라
슈퍼마리오의 카메라 처럼 일정 거리에서는 카메라가 움직이지 않고 일정거리를 넘어갔을때만 카메라가 이동함.
// If the player has moved beyond the x margin...
if(CheckXMargin())
// ... the target x coordinate should be a Lerp between the camera's current x position and the player's current x position.
targetX = Mathf.Lerp(transform.position.x, player.position.x, xSmooth * Time.deltaTime);
// If the player has moved beyond the y margin...
if(CheckYMargin())
// ... the target y coordinate should be a Lerp between the camera's current y position and the player's current y position.
targetY = Mathf.Lerp(transform.position.y, player.position.y, ySmooth * Time.deltaTime);
-> 마진 체크 후 카메라 이동
->Lerp 가 결국에는 targetY에 대입이 되며 targetY값은 계속 증가 결국 플레이어의 위치값과 똑같아짐
// The target x and y coordinates should not be larger than the maximum or smaller than the minimum.
targetX = Mathf.Clamp(targetX, minXAndY.x, maxXAndY.x);
targetY = Mathf.Clamp(targetY, minXAndY.y, maxXAndY.y);
// Set the camera's position to the target position with the same z component.
transform.position = new Vector3(targetX, targetY, transform.position.z);
-> 카메라 최대 거리 제한
결국엔 히어로의 값이랑 메인카메라랑 값이 똑같아 져야 되지만 카메라의 위치를 제한을 둬서 일정거리까지는 이동을 하지 못함
'잡다한것들전부 > 공식예제' 카테고리의 다른 글
| killTrigger -> 모든 적과 주인공 충돌(강) - Removver 스크립트 (0) | 2014.02.25 |
|---|---|
| 플레이어의 체력 - PlayerHealth (0) | 2014.02.25 |
| 플레이어 무기 발사 - gun 스크립트 (0) | 2014.02.25 |
| 주인공을 따라다니는 카메라 (0) | 2014.02.25 |
| 플레이어 컨트롤 스크립트 (0) | 2014.02.25 |
| 배경 시차 스크롤 카메라의 움직임에따라 (0) | 2014.02.25 |
Taunt -> 점수 획득시 호출 -> 플레이어 웃음 소리 랜덤으로 발생 -> 같은 웃음소리면 다시 호출해서 다른 웃음소리가 나올때까지 호출함(재귀호출)
Linecast-> 라인 캐스트를 사용해서 플레이어의 밑이 Ground인지 파악한다. -> 오브젝트의 레이어 이름이 Ground여야 됨..
groundCheck -> 빈 게임 오브젝트를 캐릭터 밑에 위치 시킴. 인스펙터창에서 모양을 지정해줄수있어서 어디 위치했는지 쉽게 알수 있음.
if(h * rigidbody2D.velocity.x < maxSpeed)
rigidbody2D.AddForce(Vector2.right * h * moveForce);
if(Mathf.Abs(rigidbody2D.velocity.x) > maxSpeed)
rigidbody2D.velocity = new Vector2(Mathf.Sign(rigidbody2D.velocity.x) * maxSpeed, rigidbody2D.velocity.y);
'잡다한것들전부 > 공식예제' 카테고리의 다른 글
| killTrigger -> 모든 적과 주인공 충돌(강) - Removver 스크립트 (0) | 2014.02.25 |
|---|---|
| 플레이어의 체력 - PlayerHealth (0) | 2014.02.25 |
| 플레이어 무기 발사 - gun 스크립트 (0) | 2014.02.25 |
| 주인공을 따라다니는 카메라 (0) | 2014.02.25 |
| 플레이어 컨트롤 스크립트 (0) | 2014.02.25 |
| 배경 시차 스크롤 카메라의 움직임에따라 (0) | 2014.02.25 |
배경 시차 스크롤 카메라의 움직임에 따라서 배경의 움직임이 달라짐.
Background 빈 오브젝트에 각각의 값들을 집어넣으면 그 값들은 각각의 속도가 다름..
뭔가 파악하기 어려운 소스지만.. 일단 대강은 이해가 감.
카메라를 이동가능하게 만듬..
parallaxScale -> 시차 스크롤링 속도 (카메라의 움직임에 따라 값이 클수록 더 빨리 배경이 움직임)
parallaxReductionFactor -> 각 레이어 별 시차 스크롤 속도 차이 값이 클수록 각 레이어별로 속도 차이가 크다.
smothing -> Lerp 함수에 입력된 값
'잡다한것들전부 > 공식예제' 카테고리의 다른 글
| killTrigger -> 모든 적과 주인공 충돌(강) - Removver 스크립트 (0) | 2014.02.25 |
|---|---|
| 플레이어의 체력 - PlayerHealth (0) | 2014.02.25 |
| 플레이어 무기 발사 - gun 스크립트 (0) | 2014.02.25 |
| 주인공을 따라다니는 카메라 (0) | 2014.02.25 |
| 플레이어 컨트롤 스크립트 (0) | 2014.02.25 |
| 배경 시차 스크롤 카메라의 움직임에따라 (0) | 2014.02.25 |
parallax.unitypackage

