- Home /
FP Camera vertical orbit around "poles" of an object
Hello, I'm a new user of Unity and have done several tutorials on standard first person games, but am now trying to do something different. I'm using PC keyboard controls.
I'd like a first person controlled camera which is confined to orbit a specific object at the centre of the scene. I'd like the left/right arrow keys to make the camera orbit horizontally around the "equator" of the object and the up/down arrow keys to make the camera orbit vertically around the "poles". I thought the easiest way to do this would be to just copy and tweak the FPSInputController, CharacterMotor and MouseLook scripts.
I got the horizontal orbit really easily by changing the MouseLook script to this:
public Transform targetLookAt;
void Update()
{
transform.LookAt(targetLookAt);
}
But the vertical one is escaping me. I tried changing line 11 in the FPSInputController script to say this:
var directionVector = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"),0);
Thinking that it would use the up/down arrow input for the Y axis, but it doesn't work, I'm guessing because with the standard CharacterMotor the Y axis is set by jumping (or falling).
I'm sure there's a much easier way to do this than I'm trying to do it, probaby by writing a script from scratch rather than trying to hack the FPS ones about. Any advice on the best way to tackle would be much appreciated!
Thanks.
there are many, many questions on here about "orbit", also di dyou try the "orbit" script freely supplied by Unity ? also try using google, "unity3D orbit script"
I tried the $$anonymous$$ouseOrbit script but this just made the camera look around itself, not orbit the object. I also looked at lots of other questions on here with "orbit" in them & used a websearch but I didn't find something that I could understand. Sorry if its a dumb question but the FAQ does say its Ok to ask any questions :)
Your answer
