I have made an endless runner game and have been testing it on mobile. The player moves across the screen automatically and then you hold down the screen to move the player up in the air. After i hold down the screen to move the character up the movement of the screen and the player goes slower, and then after letting go the character lurches forward. This is the code i use to make the character to move up, I have no clue if this is the problem but here it is. if (Input.touchCount > 0 && jetPackFuel >= 0.001f)
note: i am working in C#
This is the script i used to make the camera follow the player
public class Camera_follow : MonoBehaviour
{
private GameObject player;
public float cameraSpeed = 5.0f;
// Use this for initialization
void Start()
{
player = GameObject.FindGameObjectWithTag("Player");
}
// Update is called once per frame
void FixedUpdate()
{
if (GameUnit.gameIsPlaying == true)
{
//X positon follow
Vector3 camPos = transform.position;
camPos.x = player.transform.position.x + 8.0f;
transform.position = Vector3.Lerp(transform.position, camPos, 3 * Time.fixedDeltaTime);
//y position follow
camPos.y = player.transform.position.y + 2;
transform.position = Vector3.Lerp(transform.position, camPos, 2.0f * Time.fixedDeltaTime);
}
else {
Vector3 deathCamPos = transform.position;
deathCamPos.x = player.transform.position.x;
transform.position = Vector3.Lerp (transform.position, deathCamPos, 2.0f * Time.fixedDeltaTime);
}
}
}
And then is the code i used to make the character move forward
public class Player_move : MonoBehaviour {
public static int playerSpeed = 10;
void FixedUpdate()
{
gameObject.transform.Translate(Vector3.right * playerSpeed * Time.fixedDeltaTime);
}
}