플레이어 체력 감소, 점프, 달리기, 피격 상태 추가
This commit is contained in:
@@ -1025,9 +1025,9 @@ GameObject:
|
|||||||
- component: {fileID: 313304223}
|
- component: {fileID: 313304223}
|
||||||
- component: {fileID: 313304222}
|
- component: {fileID: 313304222}
|
||||||
- component: {fileID: 313304221}
|
- component: {fileID: 313304221}
|
||||||
m_Layer: 0
|
m_Layer: 8
|
||||||
m_Name: break_floor_0009_a1_0
|
m_Name: break_floor_0009_a1_0
|
||||||
m_TagString: Untagged
|
m_TagString: Platform
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
@@ -2331,7 +2331,7 @@ GameObject:
|
|||||||
- component: {fileID: 1008441676}
|
- component: {fileID: 1008441676}
|
||||||
- component: {fileID: 1008441675}
|
- component: {fileID: 1008441675}
|
||||||
- component: {fileID: 1008441677}
|
- component: {fileID: 1008441677}
|
||||||
m_Layer: 0
|
m_Layer: 10
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Player
|
m_TagString: Player
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -2550,9 +2550,9 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1133366867}
|
- component: {fileID: 1133366867}
|
||||||
- component: {fileID: 1133366866}
|
- component: {fileID: 1133366866}
|
||||||
m_Layer: 0
|
m_Layer: 8
|
||||||
m_Name: Grid
|
m_Name: Grid
|
||||||
m_TagString: Untagged
|
m_TagString: Platform
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
@@ -2688,7 +2688,7 @@ GameObject:
|
|||||||
- component: {fileID: 1794081151}
|
- component: {fileID: 1794081151}
|
||||||
- component: {fileID: 1794081150}
|
- component: {fileID: 1794081150}
|
||||||
- component: {fileID: 1794081152}
|
- component: {fileID: 1794081152}
|
||||||
m_Layer: 0
|
m_Layer: 9
|
||||||
m_Name: Enemy
|
m_Name: Enemy
|
||||||
m_TagString: Enemy
|
m_TagString: Enemy
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
@@ -2879,7 +2879,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!212 &1991645575
|
--- !u!212 &1991645575
|
||||||
SpriteRenderer:
|
SpriteRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -2975,7 +2975,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 2119498364}
|
m_GameObject: {fileID: 2119498364}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
@@ -3028,7 +3028,7 @@ SpriteRenderer:
|
|||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_Sprite: {fileID: 442912304861412527, guid: 0649d1685c554fb40869aba923cb5af0, type: 3}
|
m_Sprite: {fileID: 442912304861412527, guid: 0649d1685c554fb40869aba923cb5af0, type: 3}
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
m_FlipX: 0
|
m_FlipX: 1
|
||||||
m_FlipY: 0
|
m_FlipY: 0
|
||||||
m_DrawMode: 0
|
m_DrawMode: 0
|
||||||
m_Size: {x: 2.1, y: 1.03}
|
m_Size: {x: 2.1, y: 1.03}
|
||||||
|
|||||||
@@ -24,10 +24,11 @@ public class PlayerMove : MonoBehaviour
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
// 점프
|
// 점프 ( 연속 점프 방지 )
|
||||||
if (Input.GetButtonDown("Jump"))
|
if (Input.GetButtonDown("Jump") && _animator.GetBool("isJumping") == false)
|
||||||
{
|
{
|
||||||
_rigidBody.AddForce(Vector2.up * jumpPower, ForceMode2D.Impulse);
|
_rigidBody.AddForce(Vector2.up * jumpPower, ForceMode2D.Impulse);
|
||||||
|
_animator.SetBool("isJumping", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 키 입력 땔때 캐릭터 멈춤
|
// 키 입력 땔때 캐릭터 멈춤
|
||||||
@@ -41,6 +42,16 @@ public class PlayerMove : MonoBehaviour
|
|||||||
{
|
{
|
||||||
_spriteRenderer.flipX = Input.GetAxisRaw("Horizontal") >= 1;
|
_spriteRenderer.flipX = Input.GetAxisRaw("Horizontal") >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 애니메이션 설정
|
||||||
|
if (MathF.Abs(_rigidBody.linearVelocity.x) < 0.5)
|
||||||
|
{
|
||||||
|
_animator.SetBool("isMoveing", false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_animator.SetBool("isMoveing", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
@@ -60,14 +71,16 @@ public class PlayerMove : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 플랫폼을 밟고 있을 때
|
// 플랫폼을 밟고 있을 때
|
||||||
if (_rigidBody.linearVelocityY < 0)
|
if (_rigidBody.linearVelocity.y < 0)
|
||||||
{
|
{
|
||||||
Debug.DrawRay(_rigidBody.position, Vector2.down, Color.red);
|
Debug.DrawRay(_rigidBody.position, Vector3.down, Color.green);
|
||||||
RaycastHit2D rayHit = Physics2D.Raycast(_rigidBody.position, Vector2.down, 0.1f);
|
|
||||||
|
RaycastHit2D rayHit = Physics2D.Raycast(_rigidBody.position, Vector3.down, 1, LayerMask.GetMask("Platform"));
|
||||||
|
|
||||||
if(rayHit.collider != null)
|
if(rayHit.collider != null)
|
||||||
{
|
{
|
||||||
// // 바닥에 닿아있을 때 애니메이션 변경
|
// // 바닥에 닿아있을 때 애니메이션 변경
|
||||||
if(rayHit.distance < 0.5f)
|
if(rayHit.distance < 0.7f)
|
||||||
{
|
{
|
||||||
_animator.SetBool("isJumping", false);
|
_animator.SetBool("isJumping", false);
|
||||||
}
|
}
|
||||||
@@ -94,6 +107,8 @@ public class PlayerMove : MonoBehaviour
|
|||||||
// 플레이어 HP 감소
|
// 플레이어 HP 감소
|
||||||
hp--;
|
hp--;
|
||||||
|
|
||||||
|
Debug.Log(hp);
|
||||||
|
|
||||||
// 무적 표시
|
// 무적 표시
|
||||||
_spriteRenderer.color = new Color(1,1,1,0.5f); // 플레이어 반투명
|
_spriteRenderer.color = new Color(1,1,1,0.5f); // 플레이어 반투명
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user