- Home /
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);
}
}
}
Answer by Dave-Carlile · Jul 07, 2017 at 03:58 PM
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.
ye line 14 was accidental, thanks for the help do you know any links for an example use of IAnimatorControllerPlayable.Play? all im looking to do is stop and animation the run while i walk vice versa only simple version. @Dave-Carlile
Unity has tutorials in the Learn section linked at the top.
https://unity3d.com/learn/tutorials/topics/animation/animator-component