I am using Transform.RotateAround
to have my player as the camera’s axis. I get the No overload for method 'RotateAround' takes one argument
error during debug test.
Here’s my code:
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject player;
private Vector3 offset;
// Use this for initialization
void Start () {
offset = transform.position - player.transform.position;
}
// Update is called once per frame
void LateUpdate () {
transform.position = player.transform.position + offset;
transform.RotateAround (player);
transform.Rotate (new Vector3 (45, 0, 0));
}
}
What’s wrong?
you are trying to rotate around the gameobject itself when you want its position. i had filled in the rest of that line here:
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour
{
public GameObject player;
private Vector3 offset;
void Start ()
{
offset = transform.position - player.transform.position;
}
void LateUpdate ()
{
transform.position = player.transform.position + offset;
transform.RotateAround (player.transform.position, Vector3.up, 100 * Time.deltaTime );
transform.Rotate (new Vector3 (45, 0, 0));
}
}
however when i ran this the camera just jittered a lot which is probably not what you want so i commented out the lines before and after it now the camera slowly rotates around the player.
public class CameraController : MonoBehaviour
{
public GameObject player;
private Vector3 offset;
void Start ()
{
offset = transform.position - player.transform.position;
}
void LateUpdate ()
{
//transform.position = player.transform.position + offset;
transform.RotateAround (player.transform.position, Vector3.up, 100 * Time.deltaTime );
//transform.Rotate (new Vector3 (45, 0, 0));
}
}