Animate a camera with a model file

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

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 component to link the camera entity to the cameraman's movements.

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

  • an animation, to animate the camera (exported separately in your modeling tool)
  • an , to play the animation
  • In the Asset View, select the animation asset you want to use to animate the camera.

Note

For instructions about how import animations, see Import animations.

  • In the Property Grid, enable Root motion.

Enable root motion

When root motion is enabled, Xenko applies the root node animation to the 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.

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

For instructions about how add cameras, see .

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

Game Studio adds an animation component to the entity.

Animation component

  • Next to Animations, click (Add) and type a name.

Game Studio adds an animation to the list.

Animation added

  • Next to the animation you added, click (Select an asset).

    The Select an asset window opens.

Select an asset

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

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

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

Note

For instructions about how to add animation scripts, see Animation scripts.

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

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

The Select an asset window opens.

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

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

  • a , the camera you want to animate
  • a model, to attach the camera to
  • a that matches the model
  • an animation, to animate the model
  • an , to play the animation
Note

FOV and near or far plane animations are ignored if you use this method.

  • 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.

  • 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.

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

Add component

Note

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

Game Studio adds a model link component to the entity.

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

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

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

Note

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