- Home /
Camera not moving on mobile
Hi!
I'm making a simple 2D game with Unity, nothing really hard to code, but I have a problem with moving the camera en 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).
(pastebin to the code because the code sample thing looks quite broken: http://pastebin.com/hPkRs56k
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);
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: My project files (RAR archive, 10Mo) https://drive.google.com/file/d/0B_7uatx4s-W0Rnc3VzZkdWZNZlU/edit?usp=sharing
Thanks to everyone reading this! :)
Your answer
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
How to make your character move? 7 Answers
Camera Follow Mouse 2 Answers