• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
-1
Question by fun4foes · Oct 14, 2016 at 11:17 PM · scripting problemerrorinfinite runner

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;
     }
 }

Comment
Add comment · Show 8
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fun4foes · Oct 15, 2016 at 01:32 AM 0
Share

@zeronev if you could help me with this i would be grateful

avatar image fun4foes · Oct 15, 2016 at 01:34 AM 0
Share

@doublemax if you an help me with this id be grateful

avatar image ArturoSR · Oct 15, 2016 at 01:42 AM 0
Share

And the problem is?, or what does not?.

avatar image fun4foes · Oct 15, 2016 at 01:54 AM 0
Share

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()

avatar image fun4foes · Oct 15, 2016 at 01:55 AM 0
Share

@$$anonymous$$oSR these are the issues above ^^^

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Frigerius · Oct 15, 2016 at 06:20 AM

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;
  }
 }




Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by b1gry4n · Oct 15, 2016 at 02:35 AM

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fun4foes · Oct 15, 2016 at 02:55 AM 0
Share

@b1gry4n i did what u said but it didnt work

avatar image b1gry4n fun4foes · Oct 15, 2016 at 03:19 AM 0
Share

i linked you the exact script you are using, cross compare your version to that one

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unexpected symbol 'return' in class, struct, or interface member declaration 3 Answers

NullReferenceException: Object reference not set to an instance of an object 1 Answer

UnassignedReferenceException 2 Answers

C# - Cannnot access variable in another script unless I get the component everytime. 1 Answer

"The associated script cannot be loaded." 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges