Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Camera moves well in game preview but not so well in actual game

$
0
0
As the title says, the camera in the project follows the object well in game view in unity editor, but won't work in the actual game file. In game file, only the LookAt function works, not the MoveTowards. Here is the script: using UnityEngine; using System.Collections; public class MiscaCamera : MonoBehaviour { public new Transform camera; public Transform rb; public float viteza; Vector3 dif; void Start () { viteza = GetComponent(); rb = GetComponent(); camera = GetComponent(); dif = camera.transform.position - rb.transform.position; } // Update is called once per frame void FixedUpdate () { camera.transform.LookAt(rb); camera.transform.Translate(rb.transform.position - dif); } } Where "viteza" means speed. I used this kind of movement because the object is set to move with time.deltaTime. Thanks.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>