Animation Starts on begin play

Hi, I have this really annoying problem and I am far too much of a beginner to unity to know how to fix it.
I have an animation clip that I only want to play if a certain ‘If’ statement is fulfilled. But at the moment it just plays on repeat whenever I begin play.

public class BloodScreenScript : MonoBehaviour
    public GameObject DeathArea;
    Animator blanim;

    public void OnTriggerStay(Collider collider)
        if (DeathArea.GetComponent<EnterDarknessScript>().counterdeath >= 7)
            blanim = GetComponent<Animator>();



I have set up an animator composition for this as well. It goes from Entry to New State to My Animation. I have made a Parameter which is ‘ShowText’ (also featured in the script) and the conditions for the connection between the New State and My Animation is set to that Condition.

I just have no idea what is wrong so any help would be muchly appreciated.

The reason this is happening is because the animation controller needs a default animation to go to. If that is the only animation you have in the controller, it will play. The best way the solve this is to create another animation in which nothing happens. Then set it as the default animation by right clicking on it and selecting “Set as layer default state”. It will then become orange. You then must make a transition between them by right clicking the new animation and selecting “Make Transition” and then clicking on the old one. Click on the transition and make sure “Has Exit Time” is false.

I fixed it.
I ended up having to set up a whole new Animation Trigger and just messing with the get component setting in my scripts.
Thanks for the help!