2D character not moving like i need it to

I want my character to move with the four arrow keys, and then change sprites accordingly with each movement. Right now, with the script I have it just stays in a fixed position and just rotates through all four sprites nonstop, and I can’t control its movements at all. Could someone possibly help me out with this?

Thanks in advance!

usingUnityEngine;
usingSystem.Collections;

publicclassPlayerController : MonoBehaviour {
publicSpriteup;
publicSpritedown;
publicSpriteright;
publicSpriteleft;
publicfloatspeed = 1f;
privatefloatmovex = 0f;
privatefloatmovey = 0f;
//privateSpriteRendererspriteRenderer;
publicGameObjectplayer;

//Usethisforinitialization
voidStart () {
player.AddComponent ();
player.GetComponent().sprite = Resources.Load(“narrative play character_0”);
//spriteRenderer = GetComponent();
//spriteRenderer.sprite = Resources.Load(“narrativeplaycharacter_0”);
}

voidUpdate ()
{
if (Input.GetKey(KeyCode.LeftArrow))
{
movex = -1;
//transform.position += Vector3.left * speed * Time.deltaTime;
player.GetComponent().sprite = Resources.Load(“narrative play character_1”);
}
elseif (Input.GetKey (KeyCode.RightArrow)) {
movex = 1;
//transform.position += Vector3.right * speed * Time.deltaTime;
player.GetComponent().sprite = Resources.Load (“narrative play character_0”);
}
else
movex = 0;
if (Input.GetKey(KeyCode.UpArrow))
{
movey = 1;
//transform.position += Vector3.up * speed * Time.deltaTime;
player.GetComponent().sprite = Resources.Load(“narrative play character_2”);
}
elseif (Input.GetKey(KeyCode.DownArrow))
{
movey = 0;
//transform.position += Vector3.down * speed * Time.deltaTime;
player.GetComponent().sprite = Resources.Load(“narrative play character_3”);
}
}

voidFixedUpdate ()
{

//GetComponent().velocity = newVector2 (movex * speed, movey * speed);
}
}

Firstly, can you edit your post & insert the code using code tags so it displays nicely formatted so it is easier to read.

Looking at it now it looks like all your lines where you are trying to move the Sprite by changing its position & then also setting its velocity in the fixed update (except all the lines associated with moving it have been commented out).

I’d recommend going back & doing the 2d tutorials on the Unity learn section to help.