Files
az_tank_remake/Assets/Scripts/PlayerMovement.cs
2022-02-24 12:56:25 +01:00

24 lines
534 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float movespeed = 5f;
public Rigidbody2D rb;
Vector2 movement;
// Update is called once per frame
void Update()
{
//Input
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
}
void FixedUpdate() {
//Movement
rb.MovePosition(rb.position + movement * movespeed * Time.fixedDeltaTime);
}
}