26 lines
531 B
C#
26 lines
531 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerMovement : MonoBehaviour
|
|
{
|
|
public float moveSpeed = 5f;
|
|
private Rigidbody2D rb;
|
|
private Vector2 movement;
|
|
|
|
private void Start()
|
|
{
|
|
rb = GetComponent<Rigidbody2D>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
movement.x = Input.GetAxisRaw("Horizontal");
|
|
movement.y = Input.GetAxisRaw("Vertical");
|
|
}
|
|
private void FixedUpdate()
|
|
{
|
|
rb.velocity = (movement * moveSpeed);
|
|
}
|
|
}
|