Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

character controller timeline

Discussion in 'Timeline' started by elpie89, Jul 9, 2018.

  1. elpie89

    elpie89

    Joined:
    Jun 30, 2014
    Posts:
    32
    I'm trying to manage the third person character controller from the timeline, for example I would like to set a destination point and move the caracther in that position.
    How can I write a custom playable behaviour that take the control of the controller?
    Thansk
     
  2. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
  3. elpie89

    elpie89

    Joined:
    Jun 30, 2014
    Posts:
    32
    acutally i need to just pass a float parameter to the animator from the behaviour or mixed behaviour script, yes i could use a navmesh but I'm tring to do it in this way, and I think there should be a way no?
     
  4. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    131
    The asset has a tool called Timeline Playables Wizard,you can use it to generate a animator custom track with a float parameter
     
  5. elpie89

    elpie89

    Joined:
    Jun 30, 2014
    Posts:
    32
    I don't need a wizard , I'm tring to understand why animator.setfloat("ParamName",value), doesn't work from timeline
     
  6. julienb

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    174
    animator.setfloat("ParamName",value) should work from timeline. Does value have the correct value?

    Here's some sample code to set a float value in a clip and then use that value in a PlayableBehaviour. You will then be able to take that value and apply it to the animator.

    Code (CSharp):
    1. public class CustomAsset : PlayableAsset
    2. {
    3.     [SerializeField] public float position;
    4.  
    5.     public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    6.     {
    7.         var playable = ScriptPlayable<CustomPlayableBehaviour>.Create(graph);
    8.         playable.GetBehaviour().position = position;
    9.         return playable;
    10.     }
    11. }
    12.  
    13. public class CustomPlayableBehaviour : PlayableBehaviour
    14. {
    15.     public float position;
    16.  
    17.     public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    18.     {
    19.         Debug.Log("Float is : " + position);
    20.         Animator animator = playerData as Animator;
    21.         animator.SetFloat("MyCurve", position);
    22.     }
    23. }
    24.  
    25. [TrackClipType(typeof(CustomAsset))]
    26. [TrackBindingType(typeof(Animator))]
    27. public class CustomTrack : TrackAsset { }
     
    tarahugger likes this.