Hi All,
Got a problem with an animation of mine. I have a set of draws that use the same animation. I applied the ‘Use Root Motion’ to get it to play at the transformations root location. However, the problem is, I will play the animation, draw opens, press the draw again, the draw closes, but if I keep opening and closing it, the close animations pushes back an extra 0.5 on the Z-Axis each time the animation is played. I can’t find the reason why!
Here’s the code I am using:
/// <summary>
/// Woohoo! Shorter code! Instead of using an if after if for each object. In this function,
/// we will react to each object that has a tag of "AnimatedObject" and we also grab the current
/// animator attatched to the object we are looking at. We set up a temporary bool that handles the on and off state.
///
/// </summary>
/// <param name="objectBoolsName"></param>
/// <param name="objectAnimator"></param>
void InteractWithAnimatedObject(string objectBoolsName, Animator objectAnimator)
{
bool objectBoolValue;
objectBoolValue = objectAnimator.GetBool(objectBoolsName);
if(objectAnimator == null)
{
Debug.Log("Error: " + objectAnimator.transform.gameObject.name + " is missing an animator component");
} else
{
objectBoolValue = !objectBoolValue;
objectAnimator.SetBool(objectBoolsName, objectBoolValue);
}
}