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;
}
}
@zeronev if you could help me with this i would be grateful
these are the issues : -Assets/ Standar assets/2D/Scripts/Platformer2DUserControl.cs(5,1) : error CS1031 : Type Expected -Assets/Standard Assets/2D/Scripts/Platformer2DUserControl.cs(12,27) : error CS1519 : Unexpected symbol '=' in class, struct, or interface member decleration -Assets/Standard Assets/2D/Scripts/Platformer2DUserControl.cs(12,66) error CS1519 : Unexpected symbol '(' in class, struct or interface member decleration -Assets/Standard Assets/2D/Scripts/Platformer2DUserControl.cs(15,14): error CS0116: A namespace can only contain types and namespace declarations -Assets/Standard Assets/2D/Scripts/Platformer2DUserControl.cs(22,14): error CS0116: A namespace can only contain types and namespace declarations -Assets/Standard Assets/2D/Scripts/Platformer2DUserControl.cs(34,1): error CS8025: Parsing error -All compiler errors have to be fixed before you can enter playmode! UnityEditor.SceneView:ShowCompileErrorNotification()
Answer by Frigerius · Oct 15, 2016 at 06:20 AM
Hi @fun4foes, I found 3 errors:
Classes body begin with { not with (
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
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;
}
}
Answer by b1gry4n · Oct 15, 2016 at 02:35 AM
Awake needs to be capitalized. CrossPlatformInput, not CrossPLatformInput
Google works faster than unity answers...
i linked you the exact script you are using, cross compare your version to that one
Your answer
Follow this Question
Related Questions
Admob Errors 1 Answer
Unexpected symbol 'return' in class, struct, or interface member declaration 3 Answers
Menu object not responding 0 Answers
UnassignedReferenceException 2 Answers