I'm creating a maze game and curently i am having delays with my android controls. I have lade the computer controls to move front and to turn left and right and to jump using input.getaxis. Now on android i created buttons that work but not how i want. It can jump and turn how i want but it doesnt move properly. There are 2 problems one is that when i click it moves a bit and then i need to click again but i want to hold and it will move continuously and second problem is that when i turn the character doesnt move the corect way it goes always on x axis with input.getaxis everything works perfectly but i need something that will work for androdid like that, here is my code:
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float speed;
public float speedj;
Rigidbody rb;
static Animator anim;
void Start()
{
rb = GetComponent();
anim = GetComponent();
}
public void Walk ()
{
anim.SetTrigger ("Walk");
rb.velocity = new Vector3 (0,0,7f);
}
public void Left ()
{
transform.Rotate(0,-90f,0);
}
public void Right ()
{
transform.Rotate(0,90f,0);
}
public void Jump ()
{
anim.SetTrigger ("Jump");
rb.velocity = new Vector3 (0,4f,0);
}
public void StopVelocity ()
{
rb.velocity = Vector3.zero;
transform.Translate(0,0,0);
}
void FixedUpdate ()
{
float x = Input.GetAxis ("Horizontal") * Time.deltaTime * speed;
float z = Input.GetAxis ("Vertical") * Time.deltaTime * speed;
transform.Translate (0,0,z);
transform.Rotate (0,x,0);
if(Input.GetKey(KeyCode.Space))
{
anim.SetTrigger ("Jump");
rb.velocity = new Vector3 (0,speedj,0);
}
}
}
So this is it the fixedUpdate functionis for the computer the others are for buttons for android i am using event trigger for pointer up and down events pleasehelp me to change the code so that it will work for android like it works with Input.getAxis for computer thanks!