if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftShift)) with , PlayMode.StopAll);????

It says something about ints in error log, but i thought this worked in older unity c# correct me if i am wrong i need to get around this it is driving me mad i cannot find any links for c#, hope full using ints isn’t the only way because i have no idea how to work them(error log: error CS1503: Argument #2' cannot convert UnityEngine.PlayMode’ expression to type `int’)

thanks in advance!

public class PlayerAnimations : MonoBehaviour {

private Animator PlayerAnimator;

void Start () 
{
    PlayerAnimator = GetComponent<Animator>();
}

// Update is called once per frame
void Update () 
{
    if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftShift))
    {
        PlayerAnimator.Play("Run", PlayMode.StopAll);
        PlayMode.StopAll;
    }
    else if (!Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftShift))
    {
        PlayerAnimator.Play("Idle");
       
    }

	if (Input.GetKey(KeyCode.W))

	{
		PlayerAnimator.Play("Walk", PlayMode.StopAll);

	}
}

}

What is line 14 for? It looks like an attempt at calling a function, but PlayMode.StopAll is part of an enumeration. You pass it as a parameter to a function on line 13 and in other places. Remove that line and you should be in good shape.

Also, if you look at the documentation for the Animator.Play method it doesn’t take a PlayMode variable, so you’ll have problems there as well.

The code snippet you provided is a PlayerAnimations script written in C# for Unity. Let’s break down its functionality:

The PlayerAnimations class inherits from MonoBehaviour, which is the base class for scripts that can be attached to Unity game objects.

The PlayerAnimator variable is declared to store a reference to the Animator component attached to the same game object as the script.

In the Start method, the PlayerAnimator variable is assigned the reference to the Animator component using the GetComponent() method. This allows the script to interact with and control the Animator component.

The Update method is called once per frame. Within this method, various conditions are checked to determine which animation state to play.

If the W key and the Left Shift key are both being held down (Input.GetKey(KeyCode.W) and Input.GetKey(KeyCode.LeftShift)), it plays the “Run” animation using PlayerAnimator.Play(“Run”, PlayMode.StopAll). It also has a redundant statement PlayMode.StopAll, which doesn’t have any effect here and can be removed.

If the W key is not being held down (!Input.GetKey(KeyCode.W)) but the Left Shift key is being held down (Input.GetKey(KeyCode.LeftShift)), it plays the “Idle” animation.

If only the W key is being held down, it plays the “Walk” animation using PlayerAnimator.Play(“Walk”, PlayMode.StopAll).

Essentially, this script is meant to handle the animation states of a player character based on input conditions. When specific keys are pressed or released, it triggers the corresponding animations using the Animator component referenced by PlayerAnimator.

PROVIDED BY OPEN AI