코드 정리하여 PlayerMove2로 분리
This commit is contained in:
45
Assets/Scripts/Player/PlayerMove2.cs
Normal file
45
Assets/Scripts/Player/PlayerMove2.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PlayerMove2 : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
float speed;
|
||||
[SerializeField]
|
||||
float jumpPower;
|
||||
float inputValue;
|
||||
|
||||
|
||||
Rigidbody2D rigidBody;
|
||||
SpriteRenderer spriteRenderer;
|
||||
// TODO : 걷기, 점프 등 애니메이션
|
||||
Animator animator;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
rigidBody = GetComponent<Rigidbody2D>();
|
||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
rigidBody.linearVelocityX = inputValue * speed;
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnMove(InputValue value)
|
||||
{
|
||||
inputValue = value.Get<Vector2>().x;
|
||||
}
|
||||
|
||||
private void OnJump()
|
||||
{
|
||||
rigidBody.AddForceY(jumpPower, ForceMode2D.Impulse);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user