- Home /
Question by
Syrup_Bandit · Feb 23 at 04:39 PM ·
camera-lookcamera follow
How to set a spherical limit on a camera movement on a moving and rotating object. (3d)
I am making a solar system based game where all the planets are constantly rotating, the problem is that I need a camera that follows a planet and allows for movement around the planet at a constant distance, while the planet is moving around the sun, and rotating allowing for orbiting moons.
I have tried a few movement limiting scripts, but they don't work with a spherical object.
Comment
Answer by Marioooo · Feb 23 at 07:10 PM
The only way i can see this achieved is with math... take a look at this, i think this is a good starting point https://docs.unity3d.com/ScriptReference/Transform.RotateAround.html
Thank You! I used some of the code to have the camera constantly counter rotate the planet and still allow movement.
Your answer
![](https://koobas.hobune.stream/wayback/20220613053406im_/https://answers.unity.com/themes/thub/images/avi.jpg)