Calling a function

Hello, I want to call the function Animating in the following script. However, when I save it, I receive these messages:

Assets/Scripts/PlayerController.cs(39,28): error CS0135: h' conflicts with a declaration in a child block Assets/Scripts/PlayerController.cs(39,30): error CS0135: v’ conflicts with a declaration in a child block
Assets/Scripts/PlayerController.cs(39,17): error CS1502: The best overloaded method match for PlayerController.Animating(float, float)' has some invalid arguments Assets/Scripts/PlayerController.cs(39,17): error CS1503: Argument #1’ cannot convert object' expression to type float’
Controller ‘BlockJumper’: Transition ‘’ in state ‘ArmatureAction’ uses parameter ‘IsMoving’ which is not compatible with condition type.

The code:


using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class PlayerController : MonoBehaviour {
	public float speed = 6.0F;
	public float jumpSpeed = 1000.0F;
	public float gravity = 1.0F;
	public float fallSpeed = 2.0F;
	public float h;
	public float v;
	public int stars;
	public Text starText;
	public Text winText;
	public Animator anim;
	
	private Vector3 moveDirection = Vector3.zero;

	void Start ()
	{
		SetStarCount ();
		winText.text = "";
	}

	void Update() {

		CharacterController controller = GetComponent<CharacterController>();
		if (controller.isGrounded) {
			float h = Input.GetAxisRaw ("Horizontal");
			float v = Input.GetAxisRaw ("Vertical");
			moveDirection = new Vector3(h, 0, v);
			moveDirection = transform.TransformDirection(moveDirection);
			moveDirection *= speed;
			if (Input.GetButton("Jump"))
				moveDirection.y = jumpSpeed;
		}
		moveDirection.y -= gravity * Time.deltaTime/fallSpeed;
		controller.Move(moveDirection * Time.deltaTime);
		Animating (h,v);
	}

	void OnTriggerEnter(Collider other)
	{
		if (other.gameObject.CompareTag ("Star"))
		{
			other.gameObject.SetActive (false);
			stars = stars + 1;
			SetStarCount();
		}

		if (other.gameObject.CompareTag ("Finish")) 
		{
			winText.text = "Congratulations! You finished with " + stars.ToString () + " Stars";
		}

		if (other.gameObject.CompareTag ("Void")) 
		{
			gameObject.SetActive (false);
		}
	}

	void SetStarCount()
	{
		starText.text = "Stars: " + stars.ToString ();
	}


	void Animating (float h, float v)
	{
			bool walking = h != 0f || v != 0f;
			anim.SetBool ("IsMoving", walking);
	}

}

You have global v and h and then you declare a new v and h inside Update. Some older compilers would have let you go but modern one rather indicates an error.

In this case, your global v is hidden internally. And the compiler indicates that it might not be intended.

The compiler doesn’t know what you are trying to pass into the function Animating (h,v); because you have declared variables with the same name as fields and inside Update().

public float h;
public float v;
//and
float h = Input.GetAxisRaw ("Horizontal");
float v = Input.GetAxisRaw ("Vertical");

you have to rename the variables or or use this keyword