Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by CraftyMaelyss · Jul 09, 2016 at 10:50 AM · c#animationanimator controllerbeginners

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: https://www.youtube.com/watch?v=h8oI0n5kAIg and https://www.youtube.com/watch?v=z6h3aE9LIxk

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 :)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Alpha_PsychO · Sep 25, 2016 at 05:22 AM

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.

https://www.youtube.com/watch?v=Oao-A7bkve0&list=PLiyfvmtjWC_X6e0EYLPczO9tNCkm2dzkm∈dex=3

https://www.youtube.com/watch?v=M1bEtHOE8z8∈dex=4&list=PLiyfvmtjWC_X6e0EYLPczO9tNCkm2dzkm

I hope this helps. :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

211 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I'm trying to animate a chest opening and closing, but the opening and closing animations aren't playing when they should. 1 Answer

Need Help Fixing my Double Jump with Animations in 3D 0 Answers

Player animation doesn't want to stop 0 Answers

I can't make transition from actual animation to previous one 1 Answer

Animating in c# 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges