Click here to Skip to main content
15,916,398 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
using UnityEngine;

public class PlayerController : MonoBehaviour {

public Animator animator;
void Update () {
if (Input.GetKeyDown(KeyCode.J)) {
animator.SetTrigger("sword in");
}
}

public class Identifier {
}
public Animator Update () {
if (Input.GetKeyDown(KeyCode.k)) {
animator.SetTrigger("sword out");
}
}

}


What I have tried:

i always get the error
error CS0111: Type 'PlayerController' already defines a member called 'Update' with the same parameter types . pls help me!
Posted
Updated 28-Feb-21 1:13am

You have two methods called Update in the PlayerController class, plus a dummy class declaration. Judging by this and your other question you would do well to spend some time with a good C# tutorial.
 
Share this answer
 
In C# a change in the return type does not make two methods have a sufficiently different signature that you can declare two of them and the system will sort out for you which one you meant to use when you use it. To do that, you need to supply different parameters, either in terms of count, order, or type.

In addition, your second version of the Update method will not compile as it does not at any point return an instance of the Animator class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900