Hi!
I’m making a simple 2D game with Unity, nothing really hard to code, but I have a problem with moving the
camera on mobile devices (in the editor it’s working just fine!).
Here’s the script that move the camera (custom smooth follow script. It’s following the player and the damping variable is set to 10).
using UnityEngine;
using System.Collections;
public class SmoothFollow : MonoBehaviour {
public Transform target; // The target we are following
public float positionDamping;
private Vector3 deltaPos;
// Use this for initialization
void Start () {
deltaPos = new Vector3(-4f, 1f, 0f);
}
// Update is called once per frame
void Update () {
}
public void FixedUpdate () {
Vector3 targetPosition = target.position - (Vector3.forward * 10);
//transform.position = Vector3.MoveTowards(transform.position, targetPosition + deltaPos, positionDamping * Time.deltaTime);
Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, targetPosition + deltaPos, positionDamping * Time.deltaTime);
}
}
Here’s the full project if someone
want to try it (RAR archive, 10Mo): the_majestic_ball_unity_answers.rar - Google Drive
Thanks to everyone reading this!
ps: I tried it on a Samsung Galaxy S3 (i9300)