Hi,
I want to create an animation system in Unity.
It is a character animation system with an interface like maya, 3d studio, blender etc.
The idea is to move the characters and record its positions and animations over time.
And my question is: how to do this with Unity timeline?
Is it possible to create clips at runtime and play them?
I tried to do so, but the animation was not playing.
Here is the script that I am calling on Slider Change:
Here is the video:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Timeline;
using UnityEngine.Playables;
using UnityEngine.UI;
public class TestsTimeline : MonoBehaviour
{
PlayableDirector director;
TimelineAsset timelineAsset;
public AnimationClip clip1;
public AnimationClip clip2;
public Slider sliderTimeline;
// Start is called before the first frame update
void Start()
{
director = GetComponent<PlayableDirector>();
timelineAsset = (TimelineAsset)director.playableAsset;
}
public void AddAnimationClip()
{
var newTrack = (AnimationTrack)timelineAsset.GetRootTrack(0);
director.SetGenericBinding(newTrack, gameObject);
var timelineClip = newTrack.CreateClip(clip1);
var timelineClip2 = newTrack.CreateClip(clip2);
director.RebuildGraph();
}
public void OnChangeTimeline()
{
var value = sliderTimeline.value;
director.time = value;
director.RebuildGraph();
director.Evaluate();
}
}