Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by LiamConnelley · Dec 05, 2016 at 02:36 AM · unity 5error messagemovement scriptmove an objectcompiler

how do i fix the compiler errors on unity 5? i have tried everything there is to try.

here are the errors

  1. There are inconsistent line endings in the 'Assets/CScripts/movement.cs' script. Some are Mac OS X (UNIX) and some are Windows. This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.

  2. Assets/CScripts/movement.cs(21,2): error CS1520: Class, struct, or interface method must have a return type

  3. Assets/CScripts/movement.cs(23,43): error CS1525: Unexpected symbol ;', expecting )' or ,' 4. Assets/CScripts/movement.cs(26,8): error CS1525: Unexpected symbol moveVel'

and here is my code

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class movement : MonoBehaviour {

 public float Speed = 10, jumpVelocity = 10;
 Transform myTrans;
 Rigidbody2D myBody;

 bool isGround = false;

 void Start ()
 {
     myBody = this.RigidBody2D;
     myTrans = this.Transform;

 }
 
 
 fixedUpdate ()
 {
     move(Input.GetAxisRaw("Horizontal"));
 }
     Vector2 movevel = myBody.velocity
     moveVel.x = horizontalInput* Speed;
     public void move(float horizontalInput)
 {
     myBody.velocity = moveVel;
 }

}

Please email me back on how to fix it at: Lime2004@icloud.com

Comment
Add comment · Show 1
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 TBruce · Dec 05, 2016 at 03:06 AM 0
Share

Item number 1 is not an error, they are warnings and you can ignore them. If you want to fix them there is a free asset in the asset store called Line Endings Fixer that works great at taking care of the line ending warnings.

As for your code

  1. You needed a void before fixedUpdate().

  2. fixedUpdate() is not a $$anonymous$$onoBehaviour function and will never be called. Ins$$anonymous$$d it needs to be FixedUpdate().

  3. The 2 lines above public void move are out of place, I moved them into the move function.

  4. You need a ; right after Vector2 movevel = myBody.velocity.

  5. myBody = this.RigidBody2D; should be myBody = gameObject.GetComponent<Rigidbody2D>();.

  6. myTrans = this.Transform; should be myTrans = transform;.

  7. You have movevel defined but you are referencing moveVel. I changed the definition to moveVel.

.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class $$anonymous$$ovement : $$anonymous$$onoBehaviour {
 
     public float Speed = 10;
     public float  jumpVelocity = 10;
     Transform myTrans;
     Rigidbody2D myBody;
 
     bool isGround = false;
 
     void Start ()
     {
         myBody = gameObject.GetComponent<Rigidbody2D>();
         myTrans = transform;
     }
     
     void FixedUpdate ()
     {
         move(Input.GetAxisRaw("Horizontal"));
     }
 
     public void move(float horizontalInput)
     {
         Vector2 moveVel = myBody.velocity;
         moveVel.x = horizontalInput * Speed;
         myBody.velocity = moveVel;
     }
 }

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to move a cube by flipping using keyboard input 1 Answer

Script Error: OnCollisionEnter2D 1 Answer

Why is my destroy platform script now working? NullReferenceException: Object reference not set to an instance of an object. 1 Answer

Error status 0xc0000020 unity 5.4.0f3 2 Answers

File error on new project 1 Answer


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