Unable to instantiate new player with values inherited from old player gameobject.

What I am trying to do:
Instantiate a new gameobject as the player, to replace the player model with a damaged version of the playermodel. I need to also transfer a number of variables from the original player to the newly instantiated one.

What I have used as a reference:

My problem(s):
I am either unable to understand the example above (I don’t think this is the case) or I am unable to translate it into C# *(I think this is the case). I have tried three different ways of coding it but have gotten three different errors, and can’t see where to go from here.

if(starbaseHealth == 2)
		{
			float tempTurn;
			float tempWpnSpd;
			int tempTTR;
			//instantiate the appropriate damaged base
			Rigidbody tempClone = (Rigidbody) Instantiate(damagedStarbase, transform.position, transform.rotation);
			tempTurn = tempClone.GetComponents<scriptStarbaseControls>(turnRate);
			tempWpnSpd = tempClone.GetComponents<scriptStarbaseControls>(weaponSpeed);
			tempTTR = tempClone.GetComponents<scriptStarbaseControls>(timeToReload);
			tempClone.rigidbody.velocity = rigidbody.velocity;
			tempTurn = this.turnRate;
			tempWpnSpd = this.weaponSpeed;
			tempTTR = this.timeToReload;
			
			Destroy(gameObject);
		}

Assets/Scripts/scriptStarbaseControls.cs(233,46): error CS0308: The non-generic method `UnityEngine.Component.GetComponents(System.Type)’ cannot be used with the type arguments

		if(starbaseHealth == 2)
		{
			//set up temp variables
			scriptSB tempTurn = new scriptSB();
			scriptSB tempWpnSpd = new scriptSB();
			scriptSB timeToReload = new scriptSB();
			//instantiate the appropriate damaged base
			Rigidbody tempClone = (Rigidbody) Instantiate(damagedStarbase, transform.position, transform.rotation);
			tempTurn = tempClone.GetComponents<scriptStarbaseControls>(turnRate);
			tempWpnSpd = tempClone.GetComponents<scriptStarbaseControls>(weaponSpeed);
			tempTTR = tempClone.GetComponents<scriptStarbaseControls>(timeToReload);
			tempClone.rigidbody.velocity = rigidbody.velocity;
			tempClone.tempTurn = this.turnRate;
			tempClone.tempWpnSpd = this.weaponSpeed;
			tempClone.tempTTR = this.timeToReload;
			
			Destroy(gameObject);
		}

Assets/Scripts/scriptStarbaseControls.cs(229,25): error CS0118: scriptStarbaseControls.scriptSB' is a field’ but a `type’ was expected

		if(starbaseHealth == 2)
		{
			//instantiate the appropriate damaged base
			Rigidbody tempClone = (Rigidbody) Instantiate(damagedStarbase, transform.position, transform.rotation);
			scriptSB = tempClone.GetComponents<scriptStarbaseControls>();
			tempClone.rigidbody.velocity = rigidbody.velocity;
			scriptSB.turnRate = this.turnRate;
			scriptSB.weaponSpeed = this.weaponSpeed;
			scriptSB.timeToReload = this.timeToReload;
			
			Destroy(gameObject);
		}

Assets/Scripts/scriptStarbaseControls.cs(230,25): error CS0428: Cannot convert method group GetComponents' to non-delegate type scriptStarbaseControls’. Consider using parentheses to invoke the method

Above are my three attempts with the error underneath each. Googling the error has not helped me except for the reference I linked above.

Hey!

Assets/Scripts/scriptStarbaseControls.cs(233,46): error CS0308: The non-generic method `UnityEngine.Component.GetComponents(System.Type)’ cannot be used with the type arguments

You can’t do something like this

 tempTurn = tempClone.GetComponents<scriptStarbaseControls>(turnRate); 

in C#, you need to have for example:

tempTurn = tempClone.GetComponents<theTypeOfTheComponent>().theActionOnThisType(); 

Assets/Scripts/scriptStarbaseControls.cs(229,25): error CS0118: scriptStarbaseControls.scriptSB’ is afield’ but a `type’ was expected

As it says, scriptSB is not a type but a field of your class scriptStarbaseControls. Additionnaly, check this .test is a field but a type was expected - Questions & Answers - Unity Discussions seems to be the same problem for you to understand.

Assets/Scripts/scriptStarbaseControls.cs(230,25): error CS0428: Cannot convert method group GetComponents’ to non-delegate typescriptStarbaseControls’. Consider using parentheses to invoke the method

This one is because you try to get the component scriptStarbaseControls from the newly instanciated rigidbody (tempClone). The problem is that rigidbody does not have such a component by default, so you can’t get component.
What i think you want to do here is create rigidbody, create scriptStarbaseControls, add the script to the rigidbody, then modify attributes of the script.

Cheers,

Bluk

I think I am on the right path (thanks in no small part to Bluk), with the code here:

		//check to see what the base's health has dropped to
		if(starbaseHealth == 2)
		{
			//instantiate the appropriate damaged base
			Rigidbody tempClone = (Rigidbody) Instantiate(damagedStarbase, transform.position, transform.rotation);
			scriptStarbaseControls scriptSB = tempClone.gameObject.GetComponent<scriptStarbaseControls>();
			//scriptSB = tempClone.gameObject.GetComponent("scriptStarbaseControls") as scriptStarbaseControls;
			scriptSB.turnRate = this.turnRate;
			scriptSB.weaponSpeed = this.weaponSpeed;
			scriptSB.timeToReload = this.timeToReload;
			scriptSB.starbaseHealth = 2;
			tempClone.rigidbody.velocity = rigidbody.velocity;
			
			Destroy(gameObject);
		}

However I am finding that some variables are still being dropped. Not there yet, but a lot closer than I was initially.