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 /
This question was closed Feb 26, 2018 at 12:21 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by jacktjong17 · Feb 23, 2018 at 09:33 PM · error messagenot workingnoob

Problem with my code and CANT FIND THE MISTAKE!!!

So, I got the error message: "Assets/Scripts/PhysicsObject.cs(66,47): error CS1525: Unexpected symbol `)' "

I looked through the code multiple times for the closing bracket but I can't find any misplaced ones. I also checked for other noting flaws but couldn't find any for as far as I know...

Can someone help? Here's the full list (and yes, it's pretty much entirely copied from the 2D Platformer Character Controller tutorial but I'm a huge code-noob and still learning)

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PhysicsObject : MonoBehaviour {
     
     public float gravityModifier = 1f;
     public float minGroundNormalY = .65f;
     
     protected bool grounded;
     protected Vector2 groundNormal;
     
     protected Rigidbody2D rb2d;
     protected Vector2 velocity;
     protected ContactFilter2D contactFilter;
     protected RaycastHit2D[] hitBuffer = new RaycastHit2D[16];
     protected List<RaycastHit2D>hitBufferList = new List<RaycastHit2D> (16);
     
     protected const float minMoveDistance = 0.001f;
     protected const float shellRadius = 0.01f;
 
     void OnEnable()
     {
         rb2d = GetComponent<Rigidbody2D> ();
     }
     
     void Start () 
     {
         contactFilter.useTriggers = false;
         contactFilter.SetLayerMask (Physics2D.GetLayerCollisionMask (gameObject.layer) );
         contactFilter.useLayerMask = true;
     }
     
     void Update () 
     {
         
     }
     
     void FixedUpdate () 
     {
         velocity += gravityModifier * Physics2D.gravity * Time.deltaTime;
         
         grounded = false;
         
         Vector2 deltaPosition = velocity * Time.deltaTime;
         
         Vector2 move = Vector2.up * deltaPosition.y;
         
         Movement (move, true);
     }
     
     void Movement (Vector2 move, bool yMovement)
     {
         float distance = move.magnitude;
         
         if (distance > minMoveDistance)
         {
             int count = rb2d.Cast(move, contactFilter, hitBuffer, distance + shellRadius);
             hitBufferList.Clear ();
             
             for (int i = 0; i < count; i++)
             {
                 hitBufferList.Add (hitBuffer [i]);
             }
             
             for (int i = 0; i < hitBufferList.count; i++)
             {
                 Vector2 currentNormal = hitBufferList[i].normal;
                 
                 if (currentNormal.y > minGroundNormalY)
                 {
                     grounded = true;
                     if (yMovement)
                     {
                         groundNormal = currentNormal;
                         currentNormal.x = 0;
                     }
                 }
                 
                 float projection = Vector2.Dot (velocity, currentNormal);
                 if (projection < 0)
                 {
                     velocity = velocity - projection * currentNormal;
                 }
                 
                 float modifiedDistance = hitBufferList[i].distance - shellRadius;
                 distance = modifiedDistance < distance ? modifiedDistance : distance;
             }
             
         }
         
         rb2d.position = rb2d.position + move.normalized * distance;
     }
 }

I wrote it in Notepad++ with C# syntaxis and character set UTF-8-BOM

Hope to hear from someone soon

Comment
Add comment
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

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by yummy81 · Feb 23, 2018 at 09:42 PM

Line 66 should be:

  for (int i = 0; i < hitBufferList.Count; i++)
 
 

"Count", not "count". But other than that, as far as I am concerned, everything works well.

Comment
Add comment · Show 1 · 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 jacktjong17 · Feb 25, 2018 at 07:28 PM 0
Share

Thanks yummy81, it worked :)

Follow this Question

Answers Answers and Comments

135 People are following this question.

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

Related Questions

Open File Failed - "The handle is invalid". 1 Answer

How to record/save a velocity vector and apply it later? 3 Answers

Failed to Install documentation / package.json errors 2 Answers

[noob] I have a script that theoretically should manage movement of a 2D GameObject... 1 Answer

i don't have a collab tab and i get null reception not set to an instance of an object when i try to turn it on 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