unity-atoms/Examples/Assets/Common/PlayerMove.cs
2020-03-20 01:29:39 +01:00

22 lines
576 B
C#

using UnityEngine;
namespace UnityAtoms.Examples
{
/// <summary>
/// Simple move script for the Player.
/// </summary>
[AddComponentMenu("Unity Atoms/Examples/PlayerMove")]
public class PlayerMove : MonoBehaviour
{
private float _horizontal;
private float _vertical;
private void Update()
{
_horizontal = Input.GetAxis("Horizontal");
_vertical = Input.GetAxis("Vertical");
GetComponent<Rigidbody2D>().Move(new Vector2(_horizontal, _vertical), 5f, Time.deltaTime);
}
}
}