Car Door with Animations

In depth learning on Behaviour Models is found in this course in Motive Academy.

 

Overview

In another recipe, we use Grabbables and Joints to make a car’s doors openable (see Car Door with Behaviour Model). This approach is not as great for the trunk, however, as most trunks are automated and open with a click. In this recipe, we’ll create Unity animations that automatically open and close the rear door.

Setup

  1. Make sure to follow the setup steps in Car Door with Behaviour Model to ready the Prefab

  2. Add a “Trunk Lid” Motive Scene Object to the Trunk_Lid node in the car Prefab

Create the Animations

This document assumes you have a basic understanding of Unity’s animation system and can create simple animations. This is a good starting point if not.

We’ll create two Animation Controllers that use the same clip to open and close the door. The “close” controller simply plays the clip backwards. We won’t walk through the creation step here, but here is what the two Animator Controllers look like:

Trunk_Lid_Open

Trunk_Lid_Close

Note that this one uses the same animation clip, but played with speed -1. For testing, make sure these two Animators are stored in a Resources folder so that they can be targeted by Storyflow:

Note that animations like these can also be deployed as an Asset Bundle, but for testing it’s quickest to load them directly from the Resources folder.

Set Up Storyflow

  1. Create a Unity Asset Catalog

  2. Add Trunk_Lid_Open and Trunk_Lid_Close (just the names):

     

  3. Create a Unity Animation Catalog

  4. Link two animations to these assets:

    Trunk_Lid_Close is being edited here to show the link to the underlying Unity Asset.

 

Now you can use these animations at any time in your Storyflow Scripts using the Apply Effect Resource. In this example, we open the door then close it again 5s later:

Related Articles

Recipes