Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
147 lines (84 sloc) 6.97 KB

Animate a camera with a model file

Beginner Artist

Like other entities, you can animate cameras using animations imported from 3D model files such as .3ds, .fbx, and .obj.

[!Note] To animate a camera using a model file, you first need to bake the animation using your modeling tool (eg Maya, 3ds Max or Blender). Xenko doesn't support cameras animated using target cameras.

If the camera moves independently, the simplest method is to export the camera animation as a separate file, enable the root motion option on the animation, then add the camera, animation, and animation script to the same entity. If the animations include FOV or near or far plane animations, the Xenko camera updates accordingly. With this method, you don't need a model or a skeleton.

If you want the camera to move in tandem with another animation — for example, if the camera is held by a cameraman character with its own model, skeleton and animation — use a model node link component to link the camera entity to the cameraman's movements.

Animate a camera independently

To do this, you need the following assets in your project:

  1. In the Asset View, select the animation asset you want to use to animate the camera.

    Select animation asset

    [!Note] For instructions about how import animations, see Import animations.

  2. In the Property Grid, enable Root motion.

    Enable root motion

    When root motion is enabled, Xenko applies the root node animation to the TransformComponent of the entity you add the animation to, instead of applying it to the skeleton.

    [!Note] If there is no skeleton specified in Skeleton, Xenko always applies the animation to TransformComponent, even if root motion is disabled.

  3. In the Scene Editor, select the entity that contains the camera you want to animate.

    [!Note] For instructions about how add cameras, see Cameras.

  4. In the Property Grid, click Add component and select Animations.

    Select an entity

    Game Studio adds an animation component to the entity.

    Animation component

  5. Next to Animations, click Green plus button (Add) and type a name.

    Add animation

    Game Studio adds an animation to the list.

    Animation added

  6. Next to the animation you added, click Hand icon (Select an asset).

    The Select an asset window opens.

    Select an asset

  7. Select the animation you want to use to animate the camera and click OK.

  8. Click Add component and select the animation script you want to use to animate the camera.

    Add animation script

    Game Studio adds the script to the entity as a component.

    [!Note] For instructions about how to add animation scripts, see Animation scripts.

  9. Under the script component, next to Animations, click Green plus button (Add).

    Add animation to the list

  10. Next to Clip, click Hand icon (Select an asset).

    The Select an asset window opens.

    Select an asset

  11. Select the animation asset you want to use to animate the camera and click OK.

At runtime, the camera uses the animation. If the animation includes FOV or near or far plane animations, the Xenko camera updates accordingly.

Attach the camera to a node on another model

To move a camera in tandem with another model, create a separate entity for the camera, then use a model node link component to link the entity to the correct node.

To do this, you need the following assets in your project:

[!Note] FOV and near or far plane animations are ignored if you use this method.

  1. In the Asset View, select the model you want to link the camera to. Next to Skeleton, make sure a skeleton is specified that matches the model.

  2. Make sure the entity you want to attach the camera to has the model, animation clip, and animation script components needed to animate it.

    [!Note] For instructions about how to add these, see Animation.

  3. With the camera entity selected, in the Property Grid, click Add component and select Model node link.

    Add component

    [!Note] The TransformComponent applies an offset to the model node position. If you don't want to add an offset, make sure the TransformComponent is set to 0,0,0.

    Game Studio adds a model link component to the entity.

    Model node link component

  4. Next to Target, click Hand icon and select the entity that has the model you want to link the camera to.

    Select an entity

    Alternatively, leave the Target field blank. In the Entity Tree, drag the camera entity you want to animate to the entity that contains the model. Xenko links the entity to the model on the parent entity.

    Parent and child

  5. In Node name, select the node you want to link the camera to.

    Node link

    [!Note] The entity you link to must have a model with a skeleton, even if the model isn't visible at runtime.

At runtime, the camera uses the animation.

See also