Hello! I’ve spent a whole day googling this and absolutely cannot find anything where anyone has ever spoken of how to do this.
What I’m trying to do: I have a character that’s picking up a flower. I currently have the player able to approach the flower (isinrange), and press an interact button (trigger a script on the flower to currently just destroy it if the player is in range and pressing the button). The part that is baffling me is, how do I make the character bend down and lift back up during the sequence? I’ve tried a couple different things.
For reference, I want to be able to do something akin to the animation that the character is doing when picking up the crop in this video:
I’ve tried to reference the player’s animator from within the collectflower script (the one that destroys the flower) so that when “is collected = true” occurs, “PlayerAnimator.SetTrigger(“Collect”);” where the name of the parameter in the animator is “Collect”. In the animator, my current setup is that from entry, I default to an idle blendtree, and from there transition back and forth to a movement blendtree when speed is greater than zero. For the pickup animation, I’ve made a separate blend tree for directional pickup animations, and have the transitions to and from idle set to the Collect parameter.
I don’t get any errors when I try to run this, but when I “destroy” the flower, the character absolutely does not transition to the pickup state. What am I doing wrong?
My flower collect script:
{
public bool isCollected;
public Animator PlayerAnimator; //this is to connect the player's animator
public void CollectFlower()
{
if(!isCollected)
{
isCollected = true;
Debug.Log("Flower is now collected");
PlayerAnimator.SetTrigger("Collect");
PlayerAnimator.ResetTrigger("Collect");
Destroy(gameObject);
}
}
}```