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 Ethron981 · Feb 24, 2016 at 07:15 PM · c#scripting problemerrorerror message

Script errors

I don't see why I'm getting these script errors PlayerControl.cs(219,37): error CS1519: Unexpected symbol ;' in class, struct, or interface member declaration PlayerControl.cs(221,24): error CS1519: Unexpected symbol >' in class, struct, or interface member declaration PlayerControl.cs(223,31): error CS1519: Unexpected symbol =' in class, struct, or interface member declaration PlayerControl.cs(224,24): error CS1519: Unexpected symbol =' in class, struct, or interface member declaration PlayerControl.cs(226,9): error CS8025: Parsing error PlayerControl.cs(58,5): error CS1525: Unexpected symbol }' PlayerControl.cs(211,12): error CS1525: Unexpected symbol else' PlayerControl.cs(217,10): error CS1519: Unexpected symbol if' in class, struct, or interface member declaration PlayerControl.cs(217,26): error CS1519: Unexpected symbol )' in class, struct, or interface member declaration PlayerControl.cs(219,21): error CS1519: Unexpected symbol `+=' in class, struct, or interface member declaration

in this script: using UnityEngine; using System.Collections;

public class PlayerControl : MonoBehaviour {

 Rigidbody rigidBody;
 Animator anim;

 public float speed = 4;
 public float turnSpeed = 5;

 Vector3 directionPos;
 Vector3 lookPos;

 Transform cam;
 CapsuleCollider capCol;

 float horizontal;
 float vertical;

 public PhysicMaterial zfriction;
 public PhysicMaterial mfriction;

 float targetValue;
 float curValue;
 public float lerpRate = 5;
 bool holdAttack;
 bool attack;
 public float attackTimer = 1;
 float aTimer;
 float decTimer;

 bool blocking;
 float bTimer;
 public bool blockedAttack;

 float MouseX;
 float MouseY;

 void Start()
 {
     rigidBody = GetComponent<Rigidbody>();

     cam = Camera.main.transform;
     capCol = GetComponent<CapsuleCollider>();
     SetupAnimator();
 }

 void Update()
 {
     Ray ray = new Ray(cam.position, cam.forward);

     lookPos = ray.GetPoint(100);

     HandleFriction();
     ControlAttackAnimations();
     ControlBlockAnimations()
 }   

 void FixedUpdate()
 {
     horizontal = Input.GetAxis("Horizontal");
     vertical = Input.GetAxis("Vertical");

     rigidBody.AddForce(((transform.right * horizontal) + (transform.forward * vertical)) * speed / Time.deltaTime);

     directionPos = transform.position + cam.forward * 100;

     Vector3 dir = directionPos - transform.position;
     dir.y = 0;

     rigidBody.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(dir), turnSpeed * Time.deltaTime);

     anim.SetFloat("Sideways", horizontal, 0.1f, Time.deltaTime);
     anim.SetFloat("Forward", vertical, 0.1f, Time.deltaTime);

 }

 void HandleFriction()
 {
     if (horizontal == 0 && vertical == 0) {
         capCol.material = mfriction;
     }
     else
     {
         capCol.material = zfriction;
     }
 }

 void ControlAttackAnimations()
 {
     MouseX = Input.GetAxis("Mouse X");
     MouseY = Input.GetAxis("Mouse Y");

     float mousLB = Input.GetAxis("Fire1");

     #region decide Attack Type

     if (mousLB > 0.1f) ;
     {
         decTimer += Time.deltaTime;

         int attackType = 0;

         if (Mathf.Abs(MouseX) > Mathf.Abs(MouseY))
         {
             if (MouseX < 0)
             {
                 attackType = 2;
             }
             else
             {
                 attackType = 1;
             }
         }
         else
         {
             attackType = 0;
         }

         anim.SetInteger("AttackType", attackType);

         if (decTimer > 0.5f)
         {
             holdAttack = true;
             anim.SetBool("Attacking", true);
             decTimer = 0;
         }
     }
     #endregion

     if (mousLB < 0.1f)
     {
         if (holdAttack)
             attack = true;
     }

     if (holdAttack)
     {
         if (attack)
         {
             aTimer += Time.deltaTime;

             targetValue = 1;

             if (aTimer > attackTimer)
             {
                 holdAttack = false;
                 attack = false;
                 anim.SetBool("Attacking", false);
                 aTimer = 0;
                 targetValue = 0;
             }
         }
         else
         {
             targetValue = 0;
         }
     }
     else
     {
         targetValue = 0;
     }

     if (blockedAttack)
         targetValue = 0;

     curValue = Mathf.MoveTowards(curValue, targetValue, Time.deltaTime * lerpRate);
     anim.SetFloat("Attack", curValue);
 }


 void ControlBlockAnimations()
 {
     float mousRB = Input.GetAxis("Fire2");

     if (mousRB > 0.1f) ;
     {
         decTimer += Time.deltaTime;

         if (blocking)
         {
             float blockType = 0;

             if (Mathf.Abs(MouseX) > Mathf.Abs(MouseY))
             {
                 if (MouseX < 0)
                 {
                     blockType = 2;
                 }
                 else
                 {
                     blockType = 1;
                 }
             }
             else
             {
                 blockType = 0;
             }

             anim.SetFloat("blockSide", blockType);
         }
         if (decTimer > 0.5f)
         {
             anim.SetBool("Block", true);
             blocking = true;
             decTimer = 0;
         }
     }
     
     else
     {
         anim.SetBool("Block", false);
         blocking = false;
     }

     if (blockedAttack)
     {
         bTimer += Time.deltaTime;

         if (bTimer > 1)
         {
             blockedAttack = false;
             bTimer = 0;
         }
     }
 }


 void SetupAnimator()
 {
     anim = GetComponentInChildren<Animator> ();

     foreach (var childAnimator in GetComponentsInChildren<Animator>())
     {
         if (childAnimator != anim) 
         {
             anim.avatar = childAnimator.avatar;
             Destroy (childAnimator);
             break;
         }
     }
 }

}

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

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by jgodfrey · Feb 24, 2016 at 07:45 PM

There are at least a few places where you have an "if" line that ends with a semi-colon (line 94 and 171). That'll definitely throw off the parser.

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 Ethron981 · Feb 25, 2016 at 05:28 PM 0
Share

That got rid of all my errors apart from 1: PlayerControl.cs(58,8): error CS1525: Unexpected symbol `}' Just found it I needed to add a ';' to ControlBlockAnimations() thanks a lot for your help it works great now! :)

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

Create a copy of a non MonoBehaviour class and set variables from other class 0 Answers

"The associated script cannot be loaded" 0 Answers

"The associated script cannot be loaded." 0 Answers

Сonstructor return null 0 Answers

Error stage @username 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