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;
}
}
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612111426im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
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