- Home /
Using a blend tree to animate based on a 24 hour clock
Hey all, I'm fairly new to using blend trees and am having troubles wrapping my head around how I'd approach this.
I need the tree to change between 2 animation based on the time of a 24 hour clock. I've got the time variable all set up, I just need the blend tree to function something like this:
1 - 6 = night animation
6 - 20 = day animation
20 - 24 = night animation
Any tips on how to achieve this? I might just be thinking about it in the wrong way.
Thanks for any help!
Answer by matthewosb003 · Apr 17, 2020 at 04:51 PM
oh uhm, ok let me just...
There's probably about 25 ways you could do this better but Idk when I use blend tree's in script I use this weird stuff. Not tested... and uhm Idk I made it in less than one minute so it might not work great either.
if (timeVar >= 1 && timeVar < 6)
{
animator.SetFloat("FLOATNAME", 0 /*Float value*/, 0.05f /*Damp time*/, Time.deltaTime);
}
else if (timeVar >= 6 && timeVar < 20)
{
animator.SetFloat("FLOATNAME", 1 /*Float value*/, 0.05f /*Damp time*/, Time.deltaTime);
}
else if (timeVar >= 20 && timeVar <= 24)
{
animator.SetFloat("FLOATNAME", 0 /*Float value*/, 0.05f /*Damp time*/, Time.deltaTime);
}
Probably messed it up I know, I don't actually know what you're looking for other than something to do with a time animation or something... But aye heres something?
so, change some values cause thats messy, I assume you know the basics of blend tree so I didn't go into major detail like some sweaty folk.
Your answer
![](https://koobas.hobune.stream/wayback/20220612231717im_/https://answers.unity.com/themes/thub/images/avi.jpg)