So with the help of members of the forums I made this script
using UnityEngine;
using System.Collections;
public class ThePlayer : MonoBehaviour
{
public enum Directions
{
None = 0,
Left = 1,
Right = 2,
Up = 3,
Down = 4,
upLeft = 1 3,
upRight = 2 3,
downLeft = 1 4,
downRight = 2 4
}
public bool isGrounded;
public float moveSpeed;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
float dx = Input.GetAxisRaw("Horizontal") * Time.deltaTime * moveSpeed;
float dy = Input.GetAxisRaw("Vertical") * Time.deltaTime * moveSpeed;
var direction = Directions.None;
transform.Translate(dx,0,dy);
if(dx > 0)
{
direction = Directions.Right;
Debug.Log("You Are Moving Right");
}
else if(dx < 0)
{
direction = Directions.Left;
Debug.Log("You Are Moving Left");
}
if(dy > 0)
{
direction = Directions.Up;
Debug.Log("You Are Moving Up");
}
else if(dy < 0)
{
direction = Directions.Down;
Debug.Log("You Are Moving Down");
}
if(dx > 0 dy > 0 )
{
direction = Directions.upRight;
Debug.Log("You Are Moving Up and Right");
}
else if(dx < 0 dy > 0 )
{
direction = Directions.upLeft;
Debug.Log("You Are Moving Up and Left");
}
if(dy < 0 dx > 0 )
{
direction = Directions.downRight;
Debug.Log("You Are Moving Down and Right");
}
else if(dy < 0 dx < 0 )
{
direction = Directions.downLeft;
Debug.Log("You Are Moving Down and Left");
}
if(dy == 0 dx == 0)
{
direction = Directions.None;
Debug.Log("You Are Not Moving");
}
}
}
that’s all good my problem is I want where it says something like
if(dy == 0 dx == 0)
{
direction = Directions.None;
Debug.Log("You Are Not Moving");
}
for it to change the texture on a plane and loop until the condition changes for example, the code I referenced is supposed to play idle animation, I have 6 images which will play the animation, but how to make it where it will change the images in a sequence.