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 ![]()
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.
– badatnames16