티스토리 뷰
리지디바디로 점프 - 물리적 점프
GetComponent<Rigidbody>().velocity = new Vector2(GetComponent<Rigidbody>().velocity.x, jump);
리지디바디 사용안하고 점프 - 계산식으로 만든 점프
private Vector3 moveDirection = Vector3.zero;
Vector3 targetDirection = (new Vector3(CrossPlatformInputManager.GetAxis("Horizontal") * speed, 0f, CrossPlatformInputManager.GetAxis("Vertical") * speed));
if (targetDirection != Vector3.zero)
{
moveDirection = targetDirection;
moveDirection = moveDirection.normalized;
}
moveSpeed = targetDirection.magnitude * playerSpeed;
if (controller.isGrounded)
{
verticalSpeed = 0;
if (CrossPlatformInputManager.GetButton("Jump") || Input.GetKeyDown(KeyCode.Space))
{
verticalSpeed = jumpHight;
}
}
else
{
verticalSpeed -= gravity * Time.deltaTime;
}
Vector3 movement = moveDirection * moveSpeed + new Vector3(0, verticalSpeed, 0);
movement *= Time.deltaTime;
controller.Move(movement);
'프로그래밍 언어 > 프로그래밍' 카테고리의 다른 글
[JAVA] 스트림 입출력 형식 (0) | 2016.09.30 |
---|---|
[유니티] 오브젝트 터치좌표로 이동하기 (0) | 2016.06.17 |
해시 테이블 (hash table) (0) | 2009.01.18 |
트리 (0) | 2009.01.18 |
연결 리스트 (문장<이름>) (0) | 2009.01.18 |
- Total
- Today
- Yesterday
- 유머
- 혁오
- 서울시
- 김광석
- 버즈
- 공모전
- 민경훈
- 서울특별시
- 유니티
- 고양이 깜놀
- 축제
- 문화
- 태풍발생
- 아이유
- Linked List
- 지원
- 김광석 코드
- 임창정
- 청년
- 김광석 기타 코드
- 신청
- 지원금
- 청년몽땅정보통
- 연결 리스트
- 발생후
- 청년정책
- android
- 뜻밖의 샤워
- 공연
- 안드로이드
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |