The question is answered, right answer was accepted
No overload for method 'RotateAround' takes one argument
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?
Answer by Tymewiz · Mar 18, 2016 at 11:13 PM
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));
}
}
Thanks! You really helped. I just saw this and i was trying to figure it out myself.
Yet, how would i make the camera only rotate when the player rotates?
Follow this Question
Related Questions
Recognize when ever camera looks up and turns back down 0 Answers
How do i limit the rotation of a game object in relation to a free following camera ? 0 Answers
Camera Rotates when player rotates 1 Answer
Problems with rotation after zoom (camera like Sketchfab) 0 Answers
Rotating Camera on click and drag 0 Answers