Moon Phase Simulation

Updated on January 15, 2017 in  [S] Works in progress
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
3 on January 15, 2017

Here’s a simulation I made for teaching my students about Moon Phases.

You can click and drag to move the camera around. You can also zoom with the Mouse ScrollWheel.

It’s still sort of a work in progress, so if you have suggestions, I’m all ears.

  • Liked by
  • Job
2 on January 15, 2017

That’s pretty cool!
But the up/down camera controlls are inversed of what I would expect them to be. (Just preference)
Also, you should clamp the camera (I guess) x axis rotation so it doesn’t go straight above and below the earth. It’d prevent the camera spazzing out.

on January 15, 2017

Inverse controls… DONE.
Now, for the clamping… I had thought about that… I couldn’t think of a good method off the top of my head how to address this issue. Here’s the code if you have any direct guidance.

void MoveCamera () {
  float dX = Input.GetAxis ("Mouse X");
  float dY = Input.GetAxis ("Mouse Y");
  transform.RotateAround (, Vector3.up, dX * rotSpeed);
  transform.RotateAround (, transform.right, -dY * rotSpeed);

on January 15, 2017

Afterwards you can clamp it: (pseudo)

transform.localRotation = Quaternion.Euler(Mathf.Clamp(transform.localRotation.euler.x,  -89,89),transform.localRotation.euler.y, transform.localRotation.euler.z );

Or something like that.

Show more replies
  • Liked by