Problem Animating Cooldown Player.cs(102,53): error CS0102: The type `Player' already contains a definition for `deltaTime'

Hi guys im trying to emplement a simple cooldown systesm and animate Fillamount of a gui so i can animatre it by its cooldown time.
100,44
101,23
102,31
112,1

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

public class Player : MonoBehaviour {

	//Mouse controll.
	public float speed;

	// Spacecraft Speed.
	public float Spacecraftspeed = 0;
	public float SpaceCraftAccelleration = 0.4f;
	public float SpaceCraftMaximumSpeed = 12;

	public float SpaceCraftBooster = 15;
	public float FireRate = 2;
	public Transform ship;

	//CoolDowns:
	public float Option1 = 5;
	public float Option2 = 10;
	public float Option3 = 20;
	public float Option4 = 30;
	public float FillAmountZer0 = 0;

	//get Image / Fill for cooldown animation
	public GameObject  Cooldown1;
	public GameObject  Cooldown2;
	public GameObject  Cooldown3;
	public GameObject  Cooldown4;

	//Cooldown Timers / Get Text GUI to animate Time.:
	public GameObject  Cooldown1_timer;
	public GameObject  Cooldown2_timer;
	public GameObject  Cooldown3_timer;
	public GameObject  Cooldown4_timer;


	public GameObject MainGuns;
	public GameObject Special01;
	public GameObject Special02;
	public GameObject Special03;
	public GameObject Special04;

	public Transform MainGunsLoc;
	private Transform GunsLocation;


//---------------------------------------------------------------------------------------------------------------------
// Innput Controll.
	void Update ()	{

		// Mouse Movement
		Ray hit : RaycastHit;
		if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), hit))
			transform.LookAt(hit.point);
	}






		if (Input.GetMouseButton(0))
			Debug.Log("Pressed left click.");
		// Fire Main Engine.

		if (Input.GetMouseButton(1))
			Debug.Log("Pressed right click.");
		// Fire Main guns.


		// ASDF INPUT:
		//---------------------------------------------------------------------------------------------------------------------
		if (Input.GetButtonDown("A"))
			Debug.Log("Pressed A click.");
		 GunsLocation = (Transform)Instantiate (Special01, transform.position, transform.rotation);
		Image Cooldown1 = GetComponent<Image>();
	Cooldown1.fillAmount += 1.0f/Option1 * Time.deltaTime;

		//---------------------------------------------------------------------------------------------------------------------
		if (Input.GetButtonDown("S"))
			Debug.Log("Pressed S click.");
		 GunsLocation = (Transform)Instantiate (Special02, transform.position, transform.rotation);
		Image Cooldown2 = GetComponent<Image>();
	Cooldown2.fillAmount += 1.0f/Option2 * Time.deltaTime;

		//---------------------------------------------------------------------------------------------------------------------
		if (Input.GetButtonDown("D"))
			Debug.Log("Pressed D click.");
		 GunsLocation = (Transform)Instantiate (Special03, transform.position, transform.rotation);
		Image Cooldown3 = GetComponent<Image>();
	Cooldown3.fillAmount += 1.0f/Option3 * Time.deltaTime;

		//---------------------------------------------------------------------------------------------------------------------
		if (Input.GetButtonDown("F"))
			Debug.Log("Pressed F click.");
		 GunsLocation = (Transform)Instantiate (Special04, transform.position, transform.rotation);
		Image Cooldown4 = GetComponent<Image>();
	Cooldown4.fillAmount += 1.0f/Option4 * Time.deltaTime;
		
		}







}

Well, the deltaTime message doesn’t make too much sense but there are some other problems with your code which aren;t helping things.

Firstly, all your IF statements for the ASDF input are fairly meaningless as you don’t enclose the code you want to execute within {}. If you don’t do this, then only line immediatly following the if statement will be executed if the condition passes. Example:

if (Input.GetButtonDown("A"))
             Debug.Log("Pressed A click.");
Debug.Log("This will be called every time no matter is A is pressed or not");

So, wrap up your if statements to be more like:

if (Input.GetButtonDown("A"))
{
             Debug.Log("Pressed A click.");
          GunsLocation = (Transform)Instantiate (Special01, transform.position, transform.rotation);
         Image Cooldown1 = GetComponent<Image>();
     Cooldown1.fillAmount += 1.0f/Option1 * Time.deltaTime;
}

This will make sure that the code above will be executed if and only if A is pressed vs what you had, which would execute everything every time aside from the Debug.Log message, which would only execute when A was pressed.

Another problem is that you define Cooldown1 as a game object at the top of your script. Later on however you’re trying to create another object with the exact same name (Cooldown1). This can’t be done. In your case it’s a double problem as you are trying to make the Cooldown1 object as an Image, which it isn’t, it’s a gameobject.

So, to fix that either use different naming for the member variable defined at the top of the file and the local variable defined within Update, or look at what you actually want to do. Could you just define the member variable as an Image rather than a game object. This would turn the code into something more like:

if (Input.GetButtonDown("A"))
 {
              Debug.Log("Pressed A click.");
           GunsLocation = (Transform)Instantiate (Special01, transform.position, transform.rotation);
          if(Cooldown1 == null)
{
Cooldown1 = GetComponent<Image>();
}
      Cooldown1.fillAmount += 1.0f/Option1 * Time.deltaTime;
 }

Of course, this means that Cooldown1 will be a reference to an image component attached to the current game object. That’s fine so long as you only have one image component. If you have more, then this will be the first one found (and Cooldown1, Cooldown2 etc will probably all have the same reference). For that reason I’d suggest you declare your Cooldown member variable as an image and link it within the editor.

There are a couple of other things you should be doing too, but if you solve these issues then you’ll probably fix the error (or at least have more information about it). Once working, you can tidy up a bit more.