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 ThunderTurtle666 · Feb 19, 2017 at 04:13 AM · 2d platformer

Receiving no overload for method

Please help have been looking for a while and cant seem to find a fix This is the error: Assets/Robotcontroller1.cs(44,9): error CS1501: No overload for method SetFloat' takes 1' arguments

This is my script any help would be much appreciated

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Robotcontroller1 : MonoBehaviour { //how fast the robot can move public float topspeed = 10f; //tell the sprite which way its faceing bool faceingRight = true;

 //get reference to animator
 Animator anim;

 //not grounded
 bool grounded = false;

 //transform at robots foot to see if he is touching the ground 
 public Transform groundCheck;
 
 //how big the circle is going to be when we check distance to the ground 
 float groundRadius = 0.2f;

 //force of the jump 
 public float jumpForce = 700f;
 
 //what layer is considered the ground 
 public LayerMask whatIsGround;

 void Start()
 {
     anim = GetComponent<Animator>();
 }
 
 //physics in fixed update
 void FixedUpdate()
 {
     //true or false did the ground transform hit the whatIsGround with the groundRadius
     grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);

   // tell the animator that we are grounded
   anim.SetBool("Ground", grounded);

   //get how fast we are moving up or down from the Rigidbody2D
   anim.SetFloat("vSpeed, GetComponent<Rigibody2D>().velocity.y");

     //get move direction
     float move = Input.GetAxis("Horizontal");

 //add velocity to the rigibody in the move direction * our speed
 GetComponent<Rigidbody2D>().velocity = new Vector2(move * topspeed, GetComponent<Rigidbody2D>().velocity.y);

 anim.SetFloat("Speed", Mathf.Abs(move));
 
 //if we're facing the negative direction and not faceing right, flip 
  if (move > 0 && !faceingRight)
     Flip();
  else if (move < 0 && faceingRight)
     Flip();

}

 void update()
 {
     if (grounded && Input.GetKeyDown(KeyCode.Space))
     {
         //not on the ground
         anim.SetBool("Ground", false);

         ///add jump force to the y axsis of the rigibody
         GetComponent<Rigidbody2D>().AddForce(new Vector2(0, jumpForce));
     }
 }
 void Flip()
 {
     //saying we are facing the oppisite directions
     faceingRight = !faceingRight;

     //get the local scale
  Vector3 thescale = transform.localScale;

  //flip on x axis 
  thescale.x *= -1;

  //apply that to the local scale 
  transform.localScale = thescale;        
 }

}

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

Answer by oStaiko · Feb 19, 2017 at 06:38 AM

Line 34

 anim.SetFloat("vSpeed, GetComponent<Rigibody2D>().velocity.y");

See how you have qutation marks covering the entire input? What that means to the code is it's all one string, it should be:

 anim.SetFloat("vSpeed", GetComponent<Rigibody2D>().velocity.y);

That type of error basically means your input for a method has too few or too many parameters, like in this case where it technically has one (a long string) instead of the required two.

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

94 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

Related Questions

Why is it when i make walls in unity 2d my sprite stays on the wall ? 0 Answers

[2D] Rigid body snaps through floor and back 1 Answer

Issues with an event tigger 0 Answers

How to make rect transform work for ui image to make joystick? 0 Answers

2D Platformer Camera follow on y and continue to go right on x 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