Home » c# » c# – This is a code that I followed in a YouTube video and it doesn't work-Exceptionshub

c# – This is a code that I followed in a YouTube video and it doesn't work-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I followed this YouTube tutorial code up to 11:55 in it and did exactly everything but I’m getting two errors:

The name ‘Move’ does not exist in the current context and method must have a return type.

This is the code for blend tree to move the character with animation:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    private Animator _animator;



    // Start is called before the first frame update
    void Start()
    {
        _animator = GetComponent<Animator>();

    }

    // Update is called once per frame
    void Update()
    {
        if (_animator == null) return;

        var x = Input.GetAxis("Horizontal");
        var y = Input.GetAxis("Vertical");

        Move(x, y);
    }
    private Move(float x, float y)
    {
        _animator.SetFloat("VelX", x);
        _animator.SetFloat("VelY", y);
    }

}
How to&Answers:

Change this line

private Move(float x, float y)

to look like

private void Move(float x, float y)

The problem is that you haven’t specified a return type for the method.