I am trying to make a top down 2D game, sort of in the style of classic Zelda, at least the movement. Thats all i need to start moving on and ive been stuck looking for help on this for days now. I know its so simple, but i cant seem to figure it out. This is what i have, i just copied the movement up and pasted it 3 times because i figured it would be same just different vector. But I dont know what i need to put in its place for the other directions. Please help!!
#pragma strict
//Inspector Variables
var playerSpeed : float = 10; //speed player moves
function Update ()
{
MoveForward(); // Player Movement
}
function MoveForward()
{
if(Input.GetKey("up"))//Press up arrow key to move forward on the Y AXIS
{
transform.Translate(0,playerSpeed * Time.deltaTime,0);
}
if(Input.GetKey("up"))//Press up arrow key to move forward on the Y AXIS
{
transform.Translate(0,playerSpeed * Time.deltaTime,0);
}
if(Input.GetKey("up"))//Press up arrow key to move forward on the Y AXIS
{
transform.Translate(0,playerSpeed * Time.deltaTime,0);
}
if(Input.GetKey("up"))//Press up arrow key to move forward on the Y AXIS
{
transform.Translate(0,playerSpeed * Time.deltaTime,0);
}
}