Unity C# Script error: CS1501

With the game I’m making, I’m trying to connect the jump animation to the player so when you press space the jump animation will play. Now up to this point I’ve followed this tutorial: Blender Character To Unity part 1 of 2 - YouTube
and
Blender Character To Unity part 2 of 2 - YouTube

to connect both the idle and walk animations to the player model and both work fine. Now I’ve tried the same method with the jump animation and got a parsing error(which after a bit of fiddling and experimenting I fixed) this is what the code looked like before I fixed it:

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {

private Animator anim;

// Use this for initialization
void Start () {
	anim = gameObject.GetComponentInChildren<Animator> ();
}

// Update is called once per frame
void Update () {
	
	if (Input.GetKey ("w")) {
		anim.SetInteger ("AnimPar", 1);
	} else {
		anim.SetInteger ("AnimPar", 0);
	}

	if (Input.GetKey ("space")){
			anim.SetInteger ("AnimPar", 2);
		} else {
			anim.SetInteger ("AnimPar", 0);
}
}

}

Now when I fixed it, I encountered this error:
“error: CS1501: no overload for method ‘SetInteger’ takes `1’ arguments”

This is what my current C# script looks like:

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {

private Animator anim;

// Use this for initialization
void Start () {
	anim = gameObject.GetComponentInChildren<Animator> ();
}

// Update is called once per frame
void Update () {
	
	if (Input.GetKey ("w")) {
		anim.SetInteger ("AnimPar", 1);
	} else {
		anim.SetInteger ("AnimPar", 0);
	}

	if (Input.GetKeyDown ("space")){
			anim.SetInteger ("Jump");
		} else {
			anim.SetInteger ("Jump");
}
}

}

I’m very new to Unity and I’m just learning how to write these codes through youtube video tutorials. So far the most difficult thing I’ve run into is trying to get the jump animation to trigger when the character jumps ^_^; I would greatly appreciate any help on where I’ve gone wrong here :slight_smile:

The custom inspector part works fine. But its not letting me change things. Like the custom inspector is to create new items that are needed for the different orders in the game. So it has the name of the item, the icon, and the amount needed. and for example i want to change the text for how much wheat is needed for the order but when i try to nothing happens at all. Or if i'm trying to check to see if my inventory contains the amount needed it just wont do anything. Sorry i'm trying to explain it the best i can.

1 Answer

1

Hi @CraftyMaelyss, I’m pretty new to Unity as well, but I think your problem is that on lines 20 and 22 your “Jump” needs to have an integer, like you used with

(“AnimPar”, 1)

So, whatever integer you are using to get your animation to switch to jump add it in.
(“Jump”, /integer that tells jump which animation to use/)

Also, if that doesn’t help I used these vids to learn how to animate. I see from the vids you watched your making a 3D game (at least I’m assuming), and these vids are for 2D. I’m not sure how different it will be from 3D to 2D, but maybe they could help. In fact, the entire playlist for these tutorials is very useful and well made. The links below are only for the two about animating.

I hope this helps. :slight_smile: