Question by
Giovarco · Mar 29, 2016 at 05:14 PM ·
camera-movementcamera rotatecamera followcamera rotation
How to rotate a camera around a spaceship freely
Hello all,
in my scene there's a spaceship that flies here and there. I would like to lock the camera to the gameobject and rotate around it both vertically and horizontally (e.g. Nexus : The Jupiter Incident camera). This is what I've written, but It's kind of buggy and I don't understand why.
using UnityEngine;
using System.Collections;
public class GestoreTelecamera : MonoBehaviour {
public GameObject unitaSelezionata = null;
private float velocita = 10.0f;//a speed modifier
void Update()
{
if(unitaSelezionata != null)
{
this.transform.LookAt(unitaSelezionata.GetComponent<Transform>().transform);
this.transform.RotateAround(unitaSelezionata.GetComponent<Transform>().position, Vector3.up+Vector3.right, Input.GetAxis("Mouse X") * velocita);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Top-Down Camera view (with rotation) need help (third person script) 0 Answers
Spyro Like Camera Follow 0 Answers
Camera Roll/Headbob? 0 Answers
C# Smooth Follow Space Ship 1 Answer
Fixed Camera rotate to follow player 2 Answers