Hi I new to unity and I made this simple code but every time I end up with the error code CS0111 here is the code. Thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cube : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
moveSpeed = 1f;
}
// Update is called once per frame
void Update()
{
transform.Translate(moveSpeed * Input.GetAxis(“Horizontal”) * Time.deltaTime, 0f, moveSpeed * Input.GetAxis(“Vertical”) * Time.deltaTime);
}
}
Remember: NOBODY memorizes error codes. The error code is absolutely the least useful part of the error.
The important parts are: the description of the error itself, the file it occurred in, and the line number and character position.
All of that information is in the actual error message and you must pay attention to it.
How to understand compiler and other errors and even fix them yourself:
If you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: Using code tags properly
2 Likes
Nobody memorizes error codes, but you’ve got two Update functions, and that’s not allowed. I bet the message on that error tells you exactly that.
Mauri
4
Error CS0111 means “Type ‘class’ already defines a member called ‘member’ with the same parameter types”.
CS0111 occurs if a class contains two member declarations with the same name and parameter types.
In your case, Cube is your ‘class’ (obviously) and “Update” is the member. You can’t have two of the same in one class.