Hi all,

Here i have a simple character controller script that attaches to a gui texture. The texture being a left arrow and a right one. Two seperate gui textures.

I have tried countless times to add the character as a variable in this but everytime i get a error flagged. If someone could help me out that would be brilliant!

public class Movement : MonoBehaviour {
	
	public Texture2D button1;
	public Texture2D button2;
  //public GameObject Player; <--------nothing wrong here i don't think

    void Start () 
	{
		guiTexture.texture = button1;	
	}
	

	void Update () 
	{
		foreach (Touch touch in Input.touches)
		{
			if (guiTexture.HitTest(touch.position) && touch.phase != TouchPhase.Ended)
			{
				guiTexture.texture = button2;
				
				transform.Translate(Vector3.right * 30 * Time.smoothDeltaTime);
				
				
			}
			else if (guiTexture.HitTest(touch.position) && touch.phase == TouchPhase.Ended)
			{
				guiTexture.texture = button1;
			}
		}
	}
}

OK I have implemented a solution. I forgot to add the ‘Player’ in front of the transform here is the amended line of code for anyone else who wants to use it :slight_smile: no problems with anyone using it by the way.

Player.transform.Translate(Vector3.right * 30 * Time.smoothDeltaTime);

Have you tried another variable name than “character”? It can cause errors since it is pre-defined for keyboard chars.

I have an idea where to go and mark this as answered. Thanks mod :slight_smile: