- Home /
Camera move belong a certain path
i want to control the camera to look around a certain object(which stable in the middle it wont move )in different direction for example my mouse move to right hand side the camera will surround the object clockwise.
thank for answering my question
Answer by PetterDK · Apr 05, 2012 at 10:40 AM
As with your other question about the mouse-over event, your english unfortunately makes it hard to understand fully what it is you want to do..
For the sake of an answer to one possible question: If what you want is to rotate your camera around an object like it's "orbiting" around it, you could start by getting your camera to always look at the object. You can do that pretty simple with the Transform.LookAt() function.
The part about if the mouse is on the right hand side of the screen you could use Input.mousePosition. A simple script for this would be something like this:
using UnityEngine;
using System.Collections;
public class mousePosition : MonoBehaviour {
private Vector3 position;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
position = Input.mousePosition;
if (position[0] <= Screen.width/2){
print("Left side..");
}
else if (position[0] >= Screen.width/2) {
print("Right side..");
}
}
}
All you have to do with the script is to add the rotation that you want around your object..
Don't be sorry, it was just to tell you that my answer may not have been what you were looking for :) Please spread karma by upvoting.. Hope you solve your program$$anonymous$$g problems.
Your answer
Follow this Question
Related Questions
Mouse control rotate around player 0 Answers
Top-Down Camera Trouble 1 Answer
Wrong Camera axis after "zoom" to GameObject 0 Answers
Camera to rotate around object as well as follow it at the same time. 3 Answers
problem with rotate camera around player 0 Answers