How to set a Bool value from a C# script into an bool value in a animator?

Pretty much the title, I already have a ground check in my C# script using

public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask; } void Update()
{ isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

So is there anyway to get this same bool balue of isGrounded into the animator? If not maybe set the animator bool = isGrounded. (Sorry about the fomating, new to both coding and asking questions here)

Your going to have to give a little bit more of an explanation here on how your animations are set up. However, it sounds like you have multiple animation clips and are wanting to transition through them inside of the animator. You can create a bool value in the animator under parameters, and call it ‘ground’.

Then in your code you would need to make sure using the unity animations put this line at the very top of your C# script:

using UnityEngine.Animations;

After that you need get a reference to the animator from the inspector by using a global serialized variable so you can change the animation parameter at run time:

[SerializeField] private Animator anim;

this line would go where you are declaring your global variables

After that you can use the function SetBool() to set a Boolean parameter in the animator you have a reference to:

anim.SetBool("Name of parameter", value);

The “Name of parameter” is what you called your parameter in the animator, and the value would be true or false in this case because it is of type boolean.

Whenever you transition to an animation clip you can add a parameter and require that the parameter is a certain value in order to transition. Use your code to change the parameters.

Here’s some more documentation:

I hope this helps.

@IBXCODECAT I have filled in certain parameters already such as Grounded, isMoving and Jump. I already have a groundcheck from a controller made by Brackeys: FIRST PERSON MOVEMENT in Unity - FPS Controller - YouTube
And what I want is to refer to that groundcheck in my Animator.

In my animator i have a walk animation that goes into a jump animation and I dont want the jumping animation to transition until the Ground Bool is true. I have another grounded bool in the animator which could do this but if it could share the value with the one from the controller it would be nicer is what im thinking. So my question is, how I could do this if even possible. Thanks for you time

Figured it out, solution was to set the Grouned variable in animator parameters to the isGrounded from my script.
anim.SetBool(“Grounded”, isGrounded);