Moving sprites


New member
Feb 18, 2016
Programming Experience
Hey all, Going to start off with a please finish reading before running away lol.
I am new to C# though not entirely programming itself and I am taking a programming course for C#.
I decided to attempt my own project and see if I had learned anything yet and I have a sprite moving well and all up down left and right.
I am wondering however how efficient the method Im using is and if there is a better way.
Id also Like to know if there's an easier way for diagonal directions then im thinking.
Lastly Im going to point out that im using Unity 4.9 at the moment for this project (thoughts on unity anyone?) ( I was told that forums usually dont accept lots of code so here is a link)

It is a bit long though not terribly i wouldn't say.

            if (Input.GetKeyUp(KeyCode.D)){  //Button depressed resets buttonlock
            MovesetD = true;                 //Moveset is reset so that on button press 
                                                         //it loads the proper sprite the first time
            buttonlock = 0;                  //buttonlock makes it so that two buttons can not be pushed at
                                                         // the same time. problematic for diagonal though an easy fix
                } else {
                    if (buttonlock == 1) {
                    if (MovesetD == true) {
                        Moveframeindex = 7f; //loads sprite 6 on first press
                        MovesetD = false;    //sets to false so that sprite 6 is not loaded
                                                                     //loaded repeatedly
                    Moveright();  //calls appropriate move function (see bottom of link)        
Last edited:
Top Bottom