I'm following a tutorial on making a game but when I wrote what they wrote it wouldn't move.
The script is attached to sprite but when I hit W, A, S or D it doesn't move.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movment : MonoBehaviour
{
// Start is called before the first frame update
public float speed = 5f;
void Start()
{
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector2 pos = transform.position;
pos.x += h * speed * Time.deltaTime;
pos.y += v * speed * Time.deltaTime;
}
}