Search Unity

Driving player animation from cinematic

Discussion in 'Animation' started by Deleted User, Nov 8, 2018.

  1. Deleted User

    Deleted User

    Guest

    Hi,
    I've been having some problems adding a cinematic in unity.
    Very simple example : "The player opens a door".
    The logic would be as follows :
    -the player enters a trigger;
    -the trigger starts the "OpenDoorCinematic" (timeline);
    -the player blends from his current position to the cinematic position;
    -the cinematic runs and the player opens the door;
    -transition back to gameplay.

    What I would like to achieve is this : Export an .fbx from Max that only contains the nodes of the animated objects. When the cinematic starts, link the objects to the cinematic and have their animations be driven by that cinematic.

    How would I go about achieving this?
    So far I've been able to run a cinematic animation on the player, but it seems that I'm limited to using animations that have the same avatar as my player. So I don't really know how to go about actually driving the player animation with an animation that has a different avatar (the avatar of the cinematic that contains both the player rig and the door).
    Also, when running the animation directly on the player, you have to sync object positions yourself. The player will just run the animation in his current position (this isn't a big issue but it does add another thing that you have to keep track of yourself).

    One option would be to actually go in drive this animation using c#, by updating each node on every update ... but would that be performant enough?

    Is there any builtin way of achieving this?

    Ideally we should be able add an animation track from an object that uses a different avatar and just link towards what node should be considered the root node. If the hierarchies match... bingo!
    After that, add a check mark to not update the nodes down the hierarchy (or better yet, not even check the hierarchies), and just drive the GameObjects' transform with the node from the cinematic (for the given example, this would be used for the door).

    Notes:
    -Hiding the player mesh and just using a cinematic mesh isn't an option. It eliminates the possibility of character customization.
    -Splitting the cinematic into different animations just adds unnecessary complexity. As soon as you start adding other characters or objects that need to transition from gameplay to the cinematic, you run into the issue that each needs to have it's animation exported individually.
    -I'm not necessarily looking to do this for a door open animation. That is just a simple example to make it easy to understand.

    Thanks,
    Marius.
     
  2. Deleted User

    Deleted User

    Guest

    Just an update:

    Driving the player nodes through script actually works very well. Haven't had the time to profile and see what kind of impact it has, but I don't expect it to be crippling. I suspect that "Runtime Rigging" will offer some ways to optimize this but that won't be here until 2019.1.

    I've made two updated modes. "Skeletal" and "GameObject". The Skeletal mode performs a hierarchical update of the objects' nodes to match the cinematic.The GameObject mode just updates the objects transform to match the "main" node in the cinematic.
    This now has the advantage that cinematics only contain nodes (no meshes) and after a cinematic passes, all gameobjects are positioned correctly. You'll still have to manage the object position after a LoadGame but this is a very easy way to maintain your cinematics (if you your game depends on them that much).