How it works...

The key element of this recipe is the Hierarchy of our game objects. All animations created with Unity's Animation View are made in local space, which means that if you animate a parent object's position or rotation, its child objects will also move or rotate, respectively.

Our Hierarchy looks like this: Planet1 | Planet2Orbit | Planet2:

  • Planet1: This is our root game object. We can move it in space and our animation will still work perfectly.
  • Planet2Orbit: This game object is the child of the Planet1 game object. It is placed in the center of Planet1. Only this object is animated in the whole Hierarchy. We use this empty game object because we may want to rotate the root planet (Planet1) and we need another object in the Hierarchy to desynchronize the rotation of Planet1 with the orbiting movement of Planet2.
  • Planet2-This game object is the child of Planet2Orbit. It is translated in the local space of Planet2Orbit in one axis only. The rotation of the Planet2Orbit game object makes Planet2 move in circles, which creates the orbiting planet effect.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.115.154