Search Unity

Play different timelines based on player choices

Discussion in 'Animation' started by ICNCdev, Aug 14, 2021.

  1. ICNCdev

    ICNCdev

    Joined:
    Aug 12, 2021
    Posts:
    6
    I am attempting to develop a game similar to a Visual Novel where the player has choices that lead them down different paths, and the player's only way of interaction is through these decision trees. I would like to be able to play different timelines depending on the preceding choice and the 'states' of certain variables.
    An example:
    If a character's strength is at 10, and they choose to fight the monster, the timeline for the character acting out killing the monster plays. If the Character's strength is at 0, and they choose to fight the monster, the timeline for the tragic death of the character plays.
    Is there a way to do this and keep it organized within unity? Ideally, I'd like to be able to create some kind of visual tree that follows each of the potential choices and plays the respective timelines at each choice. At worst, I'd hope it'd be as complex as creating a series of conditional statements that play the timeline(s) with their respective background and scene shifts when needed.

    Note: This is all 2D, everything is done with 2D sprite animations, if relevant.


    Thanks!
     
  2. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    You could set this up easily with Cinemachines StateDrivenCamera
     
  3. ICNCdev

    ICNCdev

    Joined:
    Aug 12, 2021
    Posts:
    6
    Hey Mathew, thanks for responding. Could you elaborate? I'm a little new to unity so I'm not sure what to do with those or where to learn about them.
     
  4. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    In the editor go to Window/Package Manager. In Package Manager go to Unity Registry and install Cinemachine. After that you'll have to read the Cinemachine manual or follow some tutorials but with Cinemachine you can do everything your describing and then some. I'm using it for a rail shooter and using the state driven camera to seamlessly switch cameras.
     
  5. ICNCdev

    ICNCdev

    Joined:
    Aug 12, 2021
    Posts:
    6
    Right. But would this allow me to play timelines depending on state?
     
  6. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    501
    Actually I’m not really sure sir, maybe my idea of what a visual novel is is wrong, I’ve never played one or developed one. I’m assuming your going to make all the visual pieces then use conditional statements to display them at the appropriate time.
     
  7. KalOBrien

    KalOBrien

    Administrator

    Joined:
    Apr 20, 2021
    Posts:
    89
  8. ICNCdev

    ICNCdev

    Joined:
    Aug 12, 2021
    Posts:
    6
    Sadly it seems Fungus is gone....
    But I resolved my issue by using Animator and a custom script attached to each animator state.
     
  9. ysftulek

    ysftulek

    Joined:
    Aug 14, 2015
    Posts:
    46
    This isn't really an elegant solution because complexity grows so much and you need to handle all of them well. Is there any alternative tool, timeline isn't really a tool for this. One solution is you can create different timelines for different scenarios but creating different timeline process itself is not very easy. Especially if you try to make it look natural by starting the next timeline with the last frame of the previous timeline.