Hey, So I am really new to Unity and scripting. I found a movement script that somebody else made and I am trying to use it for my own but it is not working. I am not getting any errors but when I try to test it the character does not move. Can anyone help???
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Playermovement : MonoBehaviour
{
private float speed;
private Vector2 direction;
void Update()
{
//Executes the GetInput function
GetInput();
//Executes the Move function
Move();
}
public void Move()
{
transform.Translate(direction * speed * Time.deltaTime);
}
///
/// Listen’s to the players input
///
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;
}
}
}
