Time for action – Getting a driver's license with Root Motion Controller

Fortunately, there is a prebuilt solution that, unsurprisingly, is available from Mixamo that will solve this problem for us with very little impact to our application code - the Root Motion Controller:

Time for action – Getting a driver's license with Root Motion Controller
  1. First, go back to the Asset Store and search for a package known as the Root Motion Controller. This package from Mixamo, and developed by Adam Mechtley, has all of the functionality necessary for us to drive our character using the animation data – we need only configure it:
    Time for action – Getting a driver's license with Root Motion Controller
  2. Next we need to select the Player model from our hierarchy, since this is the component of the hierarchy that we want to control with our new controller. When adding this to a similar project, just be sure to add this to the same node that contains the Character Controller, as you want movements from the Root Motion Computer to result in motion on everything at this level of the Hierarchy:

    Note

    If you were to attach the Root Motion Computer to the Soldier node, for example, the Camera Relative Controls would not be aware that the player has actually moved.

    Time for action – Getting a driver's license with Root Motion Controller
  3. Now that we have the right node in the hierarchy selected we can add the Root Motion Computer component by selecting the Mixamo menu item:
    Time for action – Getting a driver's license with Root Motion Controller
  4. In the Inspector view you will see the Root Motion Computer component added to our Game Object. And with that we're actually done with the vast majority of the work that needs to be done. So let's take it out for a test drive:
    Time for action – Getting a driver's license with Root Motion Controller
  5. Change the settings of the animations for the character, so that the default animation is set to walk:
    Time for action – Getting a driver's license with Root Motion Controller
  6. Next, set the Animation Wrap Mode for the animation to Loop so that it will play repeatedly. Now when you run the application the player will walk repeatedly forward until they walk off the world.

What just happened?

We've just accomplished a significant step! Not only have we imported animations, but we are also using the animations to drive the character around the scene. With all of our animations synchronized with the location and orientation of the player in the scene and controlled with the joysticks we can turn our attention to the gameplay elements.

..................Content has been hidden....................

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