- Home /
How to make a moon orbit your map
Hey. So I just finished my day/night cycle and am thinking that the night time looks plain and stupid without a moving moon. I have created the moon as just a sphere up high in my map but have no idea how to make it orbit around my terrain. Could someone please help me with that?
Thanks much :)
Don't know the parameters of your map and orbit, but take a look at the example script for Vector3.Slerp() as one way to implement this functionality.
float timeOfNightInSec = 120;
float pastNight = 0;
void Update()
{
pastNight += Time.deltaTime;
float percent = pastNight / timeOfNightInSec;
float positionOf$$anonymous$$oon = percent;
$$anonymous$$oon.transform.position(positionOf$$anonymous$$oon,$$anonymous$$oon.transform.position.y,$$anonymous$$oon.transform.position.z)
}
I would solve this problem like this. But for a more beautiful result you should use a sinusoid.
Your answer
Follow this Question
Related Questions
Axial tilt and moons 1 Answer
Orbit Collision Axis 0 Answers
Rotating around to a point 1 Answer
help with my orbit camera script 0 Answers
How do I combine Orbiting with mouse drag and with a button click? 0 Answers