Skip to main content
added 76 characters in body
Source Link
tmighty
  • 919
  • 1
  • 15
  • 41

My player has the following hierarchy:

Hero (GameObject)
      Model (child of "Hero", centered at 0-0-0)
      Camera (child of "Hero")

The camera should be allowed to

- change its position around the Model in a circle ("rotate around the 
  center")
- rotate so that it always faces the Model.
- move up and down
- move nearer and further from / to the Model

I know how to do that using Quaternions, but as I'm doing this in a coroutine and using Lerp, I found myself in situations where the camera would get right through the model as this was the shortest path between the destination and the target vector.

I would now like to use pure angles (Sin and Cos), preferrably without LookAt. Can somebody share how I would position and rotate the camera according to the angle, perhaps even taking a camera height variable into account as the camera should also be able to move up and down, still facing the player?

That would be the bomb!

My player has the following hierarchy:

Hero (GameObject)
      Model (child of "Hero", centered at 0-0-0)
      Camera (child of "Hero")

The camera should be allowed to

- change its position around the Model in a circle ("rotate around the 
  center")
- rotate so that it always faces the Model.

I know how to do that using Quaternions, but as I'm doing this in a coroutine and using Lerp, I found myself in situations where the camera would get right through the model as this was the shortest path between the destination and the target vector.

I would now like to use pure angles (Sin and Cos), preferrably without LookAt. Can somebody share how I would position and rotate the camera according to the angle, perhaps even taking a camera height variable into account as the camera should also be able to move up and down, still facing the player?

That would be the bomb!

My player has the following hierarchy:

Hero (GameObject)
      Model (child of "Hero", centered at 0-0-0)
      Camera (child of "Hero")

The camera should be allowed to

- change its position around the Model in a circle ("rotate around the 
  center")
- rotate so that it always faces the Model
- move up and down
- move nearer and further from / to the Model

I know how to do that using Quaternions, but as I'm doing this in a coroutine and using Lerp, I found myself in situations where the camera would get right through the model as this was the shortest path between the destination and the target vector.

I would now like to use pure angles (Sin and Cos), preferrably without LookAt. Can somebody share how I would position and rotate the camera according to the angle, perhaps even taking a camera height variable into account as the camera should also be able to move up and down, still facing the player?

That would be the bomb!

Source Link
tmighty
  • 919
  • 1
  • 15
  • 41

Move camera around player while facing player

My player has the following hierarchy:

Hero (GameObject)
      Model (child of "Hero", centered at 0-0-0)
      Camera (child of "Hero")

The camera should be allowed to

- change its position around the Model in a circle ("rotate around the 
  center")
- rotate so that it always faces the Model.

I know how to do that using Quaternions, but as I'm doing this in a coroutine and using Lerp, I found myself in situations where the camera would get right through the model as this was the shortest path between the destination and the target vector.

I would now like to use pure angles (Sin and Cos), preferrably without LookAt. Can somebody share how I would position and rotate the camera according to the angle, perhaps even taking a camera height variable into account as the camera should also be able to move up and down, still facing the player?

That would be the bomb!