error CS0111: Type 'AutoEaterBuy' already defines a member called 'Update' with the same parameter types
Can someone help me with this i can see the error?
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement;
public class AutoEaterBuy : MonoBehaviour {
public GameObject FakeButton;
public GameObject FakeText;
public GameObject RealButton;
public GameObject RealText;
public static int CurrentDollars;
public static int AutoEaterValue = 20;
public static bool TurnOffButton = false;
public GameObject AutoEaterStats;
public static int NumberOfAutoEater;
public static int AutoEaterPerSec;
void Update()
{
CurrentDollars = Dollars.dollars;
AutoEaterStats.GetComponent<Text>().text = "Auto Eaters: " + NumberOfAutoEater + " @ " + AutoEaterPerSec + " Per Second";
FakeText.GetComponent<Text>().text = "Auto eater - $" + AutoEaterValue;
RealText.GetComponent<Text>().text = "Auto eater - $" + AutoEaterValue;
if (CurrentDollars >= AutoEaterValue)
{
FakeButton.SetActive(false);
RealButton.SetActive(true);
}
if (TurnOffButton == true)
{
RealButton.SetActive(false);
FakeButton.SetActive(true);
TurnOffButton = false;
}
}
}
Answer by Bunny83 · Feb 13, 2019 at 06:48 PM
Are you sure:
This is your whole script and there isn't any other method in the same class.
you actually saved your recent changes.
you don't have another script somewhere in your project with the same name.
The error will pop up when you have two or more methods with the same name. In your case it seems you have two Update methods defined in the same class. This is not possible. Though the script you've posted only contains one Update method. So either you didn't poste the right / complete script or you haven't saved your recent changes and you previously had two Update methods.
How would this apply to my code?
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CameraController : $$anonymous$$onoBehaviour {
public Transform target;
public Vector3 offset;
public float rotateSpeed;
// Start is called before the first frame update
void Start() {
offset = target.position - transform.position;
target.transform.postition = target.transform.position;
target.transform.parent = target.transform;
}
// Update is called once per frame
void Update() {
//Get the X position of the mouse and rotate the target
float Horizontal = Input.GetAxis("$$anonymous$$ouse X") * rotateSpeed;
target.Rotate(0, Horizontal, 0);
//Get the Y position of the mouse and rotate the target/pivot
float Vertical = Input.GetAxis("$$anonymous$$ouse Y") * rotateSpeed;
target.Rotate(Vertical, 0, 0);
//$$anonymous$$ove the camera based on the rotation of the target and the original offset
float desiredYAngle = target.eulerAngles.y;
float desiredXAngle = target.eulerAngles.x;
Quaternion rotation = Quaternion.Euler(desiredXAngle, desiredYAngle, 0);
transform.position = target.position - (rotation * offset);
//transform.position = target.position - offset;
transform.LookAt(target);
}
}
If you would have asked this as an actual question I would have given you the exact same answer. I don't know what else can be said about your issue. You most likely haven't saved all your files and / or haven't waited for Unity to recognise those changes. You most likely did not get the error
Type 'AutoEaterBuy' already defines a member called 'Update' with the same parameter types
So we can't handle your question here, the question is stated in the title. If you have a question, ask a seperate question. However you should provide more information than what you have provided here in the comment. The exact error message usually comes with file names line numbers where the error has beed detected.
Thanks for your quick reply I actually solved my code. I am new to Unity!
Your answer
![](https://koobas.hobune.stream/wayback/20220612191650im_/https://answers.unity.com/themes/thub/images/avi.jpg)