im having trouble moving my character it wont move any way at all the private float shows up in my inspector and i changed it to 5 and it still wont move here is the code im using please help using im also watching this video #1.0 Unity RPG Tutorial - Player movement - YouTube to learn to code
System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField]
private float speed;
private Vector2 direction;
// Use this for intialization
void Start()
{
}
// Update is called once per frame
void Update()
{
GetInput();
Move();
}
public void Move()
{
transform.Translate(direction * speed * Time.deltaTime);
}
private void GetInput()
{
direction = Vector2.zero;
if (Input.GetKey(KeyCode.W))
{
direction += Vector2.up;
}
if (Input.GetKey(KeyCode.A))
{
direction += Vector2.left;
}
if (Input.GetKey(KeyCode.S))
{
direction += Vector2.down;
}
if (Input.GetKey(KeyCode.D))
{
direction += Vector2.right;
}
}
}