Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Driving player animation from cinematic

Discussion in 'Animation' started by Bleeckye, Nov 8, 2018.

  1. Bleeckye

    Bleeckye

    Joined:
    Nov 5, 2016
    Posts:
    3
    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. Bleeckye

    Bleeckye

    Joined:
    Nov 5, 2016
    Posts:
    3
    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).