Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How can I set specific position(Override) to character at RunTime in TimeLine??

Discussion in 'Timeline' started by Dr-Game, Feb 21, 2019.

  1. Dr-Game

    Dr-Game

    Joined:
    Mar 12, 2015
    Posts:
    161
    HIHI~
    I want use TimeLine as a template.Want to feed character ,animationclip,specific position at running time ~~
    Here is a case!!
    A Hero face Two Enemy(A and B),I want to use a timeline as a Skill template,(Hero run in front of Enemy and kick)
    Use the same Timeline by feeded differert Target(Enemy A and B).So the Hero will run different direction until reaching in front of target!!

    I reach some problem in set animationclip and specific position(run in front of Enemy.set into Animation Track);

    TimelineClip.clip.asset = MYClip;
    Seems not Work,

     
    Last edited: Feb 21, 2019
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    var asset = clip.asset as AnimationPlayableAsset;
    if (asset != null)
    asset.clip = MYClip;

    Is what you want.
     
  3. Dr-Game

    Dr-Game

    Joined:
    Mar 12, 2015
    Posts:
    161
    Amazing!! IT WORKS~~~~ ThaQ!!!!!!!
     
  4. Dr-Game

    Dr-Game

    Joined:
    Mar 12, 2015
    Posts:
    161
    HI~My teacher
    Now I can change animation clip at run time by C#.
    But here is a issue.I want my Hero go to different Enemy's Face.I need set the Position in font of Enemy at Runtime.
    The Target Enemy differ by blinding in Palyable Director at runtime
    How can I change position in the animation track (non animation clip track)at run time by C#.
    It seems to the API of animation have no method can change value by C#.
    So I need a custom track(transform) which have a position property to do this fuction?? Its the only way??
    And when I assign the gameobject(Enemy) to the custom track.It not work.
    But When I creat a EmptyGameobject have a child which is the gameobject(Enemy).It works.
    It seems the gameobject which have "Animator" cant modify the property of custom track??
    Is it right??
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You would need a different track altogether. The animation track plays back fixed-path animations, but there are a couple examples in the default playable package, like the transform tween track or the navmesh agent track that could get you started.

    For example, you could set up a transform tween track, then place the target gameObject where ever you wanted. That would give you a straight line path to the enemy.
     
  6. Dr-Game

    Dr-Game

    Joined:
    Mar 12, 2015
    Posts:
    161
    ThaQ for your guide~
    Almost finish it!! But I sticked at the final step"Change VFX at runtime".
    My VFX(Particle System) should be put in control Track or Activation Track????
    But What API I can use?? To replace(override) the VFX(Particle System) at run time in control Track???
     
    Last edited: Mar 12, 2019
  7. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You can replace the source object on control tracks using the PlayableDirector.SetReferenceValue.

    if you have the timeline clip for the control track
    var controlAsset = (ControlPlayableAsset) clip.asset;
    playableDirector.SetReferenceValue(controlAsset.sourceGameObject.exposedName, newGameObjectWithVFX).

    You can also assign the name via script:
    controlAsset.sourceGameObject.exposedName = "MyParticleSystem";

    then just use the name.
    playableDirector.SetReferenceValue("MyParticleSystem", newGameObjectWithVFX);

    The advantage here is if you have multiple control track clips with the same object, you can give them all the same name.
     
  8. Dr-Game

    Dr-Game

    Joined:
    Mar 12, 2015
    Posts:
    161
  9. Dr-Game

    Dr-Game

    Joined:
    Mar 12, 2015
    Posts:
    161
    HI~
    When I use transform tween track to desire to set deffer location at runtime.
    Such as below
    Stance_Point_0 = Starter.transform;
    Stance_Point_1 = Tageter.transform;

    myclip.startLocation = Stance_Point_0;
    myclip.endLocation = Stance_Point_1;

    but have some error appear below:
    Cannot implicitly convert type 'UnityEngine.Transform' to 'UnityEngine.ExposedReference<UnityEngine.Transform>'

    The only way to use is to drag some empty gameobject in Scene to field of startLocation and endLocation in Editor Time.....
    But I need to overwrite data in runtime!!!!
     
    Last edited: Mar 14, 2019
  10. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
  11. Dr-Game

    Dr-Game

    Joined:
    Mar 12, 2015
    Posts:
    161
  12. Dr-Game

    Dr-Game

    Joined:
    Mar 12, 2015
    Posts:
    161
    I want to change my character material tint color in timeline.I intend use the tool you mention "timeline wizard "
    but I cant find material or material property in Render??
    https://drive.google.com/file/d/1XqMUzpqMCECc77txDueBbtONDzOsMnhA/view?usp=sharing
     
  13. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You can animate material properties using record mode on the the animation track if that is easier. It's possible to create a custom track, but materials are shared so your custom track has to be careful to use material instances.