• 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 /
avatar image
0
Question by Raxis · Aug 11, 2012 at 06:39 AM · errormovement

Expecting ':' Found '=' Error

I'm getting an error saying "Expecting ':' Found '='"

This is my function I'm getting the error in:

 function Update () 
 {
   horizontalMovement = Vector2(rigidbody.velocity.x, rigidbody.velocity.z);
   if (horizontalMovement.magnitude > maxWalkSpeed) 
   {
       horizontalMovement.Normalize ();
       horizontalMovement *= maxWalkSpeed;
   }
   
   {
   rigidbody.velocity.x = horizontalMovement.x;
   rigidbody.velocity.z = horizontalMovement.y;
   }
   
   if (Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0)
   {
       rigidbody.velocity.x = Mathf.SmoothDamp(rigidbody.velocity.x, 0, walkDeaccelerationVolx, walkDeacceleration);
       rigidbody.velocity.z = Mathf.SmoothDamp(rigidbody.velocity.z, 0, walkDeaccelerationVolz, walkDeacceleration);
   }
   transform.rotation = Quaternion.Euler(0, cameraObject.GetComponent(FPSMouseLook).currentYRotation, 0);
   rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration, 0, Input.GetAxis("Vertical") * walkAcceleration);
   
   if (Input.GetButtonDown("Jump") && grounded)
       rigidbody.AddForce(0, jumpVelocity, 0);

 }

If you know how to fix this error, Please leave a comment below! Thanks in advance! The Error is on line: 26 Column: 28 -

rigidbody.velocity.x = horizontalMovement.x;

And

rigidbody.velocity.z = horizontalMovement.y;

Comment
Add comment · Show 4
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 Eric5h5 · Aug 11, 2012 at 06:43 AM 0
Share

It would help if you pointed out which line the error occurred on.

avatar image Raxis · Aug 11, 2012 at 07:00 AM 0
Share

@Eric5h5 Line 26 Column 28

avatar image Eric5h5 · Aug 11, 2012 at 07:00 AM 0
Share

That doesn't really help I'm afraid. What's line 26?

avatar image Raxis · Aug 11, 2012 at 07:02 AM 0
Share

rigidbody.velocity.x = horizontal$$anonymous$$ovement.x;

And

rigidbody.velocity.z = horizontal$$anonymous$$ovement.y;

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Eric5h5 · Aug 11, 2012 at 07:09 AM

You have braces around these lines:

 {
 rigidbody.velocity.x = horizontalMovement.x;
 rigidbody.velocity.z = horizontalMovement.y;
 }

The braces should be removed.

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

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Multiple Cars not working 1 Answer

BCE0044: Expecting : Found = Error! 2 Answers

Errors with script using Javascript. 2 Answers

Vehicle Script Help 1 Answer

Have null errors 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges