| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- c언어 배열 programming
- lua download
- 비주얼 스튜디오 다운로드
- 루아다운로드
- Lua 설명
- c언어 버블정렬
- c언어 콘서트 배열 2번
- c언어 최대최소
- lua 다운로드
- c++ 등차수열 합
- Lua language
- C언어 달력
- 게임제작
- 온라인 비주얼 스튜디오
- 메이플스토리
- 유니티
- c sharp hello world
- 비주얼 스튜디오
- c언어 콘서트 배열
- LUA
- N Queen Coordinates
- N Queen 문제
- c샾 hello world
- N Queens Problem
- for문
- 루아
- Lua란
- 2중 반복문
- c샾 헬로우 월드
- c#온라인
Archives
- Today
- Total
Ln Go
개발 일기 1 PlayerMove 본문
Rigidbody 2D 에서 Linear Drag(sometimes called air resistance)를 설정해주지 않아 Player가 계속 움직였다.
OnCollisionEnter2D()로 더블 점프를 막아주려 했지만 OnCollisionEnter()을 써버렸다.
BoxCollider2D로 진행시 다른 BoxCollider과 만나면 버벅이거나 캐릭터가 멈춘다.
CapsuleCollider2D로 바꿔주었다.
using UnityEngine;
public class PlayerMove : MonoBehaviour
{
Rigidbody2D rigid;
public float maxSpeed;
public float jumpPower;
bool isGround;
void Awake()
{
rigid = GetComponent<Rigidbody2D>();
}
void Update()
{
if (isGround)
{
if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.LeftAlt))
{
rigid.AddForce(Vector2.up * jumpPower, ForceMode2D.Impulse);
isGround = false;
}
}
}
void FixedUpdate()
{
float h = Input.GetAxisRaw("Horizontal");
rigid.AddForce(Vector2.right * h, ForceMode2D.Impulse);
if (rigid.velocity.x > maxSpeed)
rigid.velocity = new Vector2(maxSpeed, rigid.velocity.y);
else if (rigid.velocity.x < maxSpeed * (-1))
rigid.velocity = new Vector2(maxSpeed * (-1), rigid.velocity.y);
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "BackGround")
{
isGround = true;
}
}
}
'Unity > Maple Story' 카테고리의 다른 글
| 메이플스토리 유니티로 만들기 (0) | 2021.06.04 |
|---|
Comments