46 lines
886 B
C#
46 lines
886 B
C#
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);
|
|
}
|
|
}
|