Can someone help me fix this script up?

So i’ve been wanting to create an infinate runner game but I need this script to co-op with me. It says that I have many errors but all I did was copy the script from a video and in the video the guy does it and then he can play his game instantly.

Here is the script :

using UnityEngine;

[RequireComponent(typeof(PlatformerCharacter2D))]
public class Platformer2DUserControl : MonoBehavior
(
	private PlatformerCharacter2D character;
	private bool jump;


	void awake()
	{
		character = GetComponent<Platformer2DUserControl>();
	}

	void Update ()
	{
		// Read the jump input in Update so button presses aren't missed.
		if (CrossPLatformInput.GetButtonDown("Jump"))
			jump = true;
	}

	void FixedUpdate()
	{
		//read the inputs.
		//bool crouch = Input.GetKey(KeyCode.LeftControl);
		//float h = CrossPlatformInput.GetAxis("Horizontal");

		// Pass all parameters to the character control script.
		character.Move ( 1, false, jump );

		// Reset the jump input once it has been used.
		jump = false;
	}
}

Hi @fun4foes, I found 3 errors:

  1. Classes body begin with { not with (
  2. Methods have to begin with a capital letter (okay the don’t “have to” but methods like Awake and Update are called by Unity and these methods are defined with a starting capital letter) If I’m right in C# it’s a convention to start methods with a capital letter
  3. I think its CrossP l atformInput not CrossP L atformInput

so here the corrected code (not tested but I think that’s it)

using UnityEngine;

[RequireComponent(typeof(PlatformerCharacter2D))]
public class Platformer2DUserControl : MonoBehavior 
{
 private PlatformerCharacter2D character;
 private bool jump;

 //Methods like Awake and Update, must begin with a capital letter
 void Awake()
 {
     character = GetComponent<Platformer2DUserControl>();
 }
 void Update ()
 {
     // Read the jump input in Update so button presses aren't missed.
    // --> I think its CrossPlatformInput not CrossPLatformInput
    if (CrossPlatformInput.GetButtonDown("Jump"))
         jump = true;
 }
 void FixedUpdate()
 {
     //read the inputs.
     //bool crouch = Input.GetKey(KeyCode.LeftControl);
     //float h = CrossPlatformInput.GetAxis("Horizontal");
     // Pass all parameters to the character control script.
     character.Move ( 1, false, jump );
     // Reset the jump input once it has been used.
     jump = false;
 }
}

Awake needs to be capitalized.
CrossPlatformInput, not CrossPLatformInput

Google works faster than unity answers…

https://github.com/CoolOppo/Unity-Networking-FPS/blob/master/Assets/Sample%20Assets/2D/Scripts/Platformer2DUserControl.cs