0
\$\begingroup\$

I have a standard camera in my scene. With standard I mean the camera you get when you click right mouse > Camera, with no modification except for the transform position and rotation. Then I attached to the camera this simple script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour {

public GameObject target;
public Vector3 translationOffset;
public Vector3 rotationOffset;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    transform.position = target.transform.position + translationOffset;
    transform.LookAt(target.transform);
    transform.Rotate(-rotationOffset);
}

}

the result I have is this:

camera behaviour

Why my camera is doing that? It may be worth noticing that everything was working fine, but at some point i clicked on "reimport all assets" and it started this weird behaviour. How can I fix? Thanks a lot.

\$\endgroup\$
  • 1
    \$\begingroup\$ There's nothing obvious in what you've shown that would cause this. Do you have any other scripts that might be influencing the camera position? \$\endgroup\$ – DMGregory Jun 3 '18 at 20:24
  • \$\begingroup\$ @DMGregory not really, those are the only two object in the scene and the only script is the one on the camera I pasted in my question. However I deleted and I did everything back from scratch; now everything is working as expected. \$\endgroup\$ – JoulinRouge Jun 3 '18 at 20:33
  • \$\begingroup\$ Hmm when looking at the script component, the variables aren't changing, so I don't think this script is causing the issue... \$\endgroup\$ – Saryk Jun 3 '18 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.