- Home /
Camera dont move whit Smooth Follow 2D
Im try use the Script of this post in my project(http://answers.unity3d.com/questions/29183/2d-camera-smooth-follow.html) in C#, but when i add in my project and add my Target dont happen anything, i will post the script here to see best:
CamDown.cs using UnityEngine; using System.Collections;
public class CamDown : MonoBehaviour {
public float dumptime = 0.15f;
private Vector3 velocity = Vector3.zero;
public Transform target;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (target) {
Vector3 point = Camera.main.WorldToViewportPoint(target.position);
Vector3 delta = target.position - Camera.current.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, point.z));
Vector3 destination = transform.position + delta;
transform.position = Vector3.SmoothDamp(transform.position,destination, ref velocity, dumptime);
Debug.Log ("Esta aqui");
}
}
}
in script of the post he use the camera variable, im try change to Camera.main
and Camera.current
but nothing happen, please help me, thanks much.
Solved put the script inside $$anonymous$$ain Camera and replace Camera.main by camera.
Your answer
Follow this Question
Related Questions
After using NGUI, game is not scaling for different devices ??? 0 Answers
Camera script 1 Answer
Shaky player effect when I apply a damping camera follow script? 1 Answer
Cinemachine 2d camera problem 0 Answers
Smooth Camera 2D Follow Player 0 Answers