• 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 /
This question was closed Mar 18, 2015 at 02:49 PM by Graham-Dunnett for the following reason:

Duplicate Question - loads of questions tagged with that

avatar image
0
Question by Trollingsloth03 · Mar 18, 2015 at 11:49 AM · gamecs1525

Error 1525,Driving me nuts!

Problem: Assets/Scripts/PlayerController.cs(104,15): error CS1525: Unexpected symbol `private'

using UnityEngine; using System.Collections;

using Globals;

[RequireComponent(typeof(CharacterController))] [RequireComponent(typeof(HeadLookController))] [RequireComponent(typeof(PlayerAnimator))] [RequireComponent(typeof(Weapon))] public class PlayerController : MonoBehaviour

{ #region Public Fields & Properties public float idleTimer;

 public float runSpeed = 4.6f;
 public float runStrafeSpeed = 3.07f;
 public float walkSpeed = 1.22f;
 public float walkStrafeSpeed = 1.22f;
 public float maxRotationSpeed = 540f;

 //public variables that are hidden in inspecter
 [HideInInspector]
 public float targetYRotation;

 [HideInInspector]
 public bool walk;
 [HideInInspector]
 public bool inAir;
 [HideInInspector]
 public bool aim;
 [HideInInspector]
 public bool grounded;

 [HideInInspector]
 public Vector3 moveDir;
 #endregion

 #region Private Fields & Properties
 private Transform _playerTransform;

 private CharacterController _controller;

 private CharacterMotor _motor;
 #endregion

 #region Getters & Setters

 #endregion

 #region System Methods
   private void Start()
 {
     idleTimer = 0f;

     _playerTransform = transform;

     walk = true;
     aim = false;

     _controller = GetComponent<CharacterController> ();
     _motor = GetComponent<CharacterMotor> ();
     _controller.center = new Vector3 (0f, 1f, 0f);
 }

 private void Update()
 {
     GetUserInput ();

     if(!_motor.canControl)

     {
         _motor.canControl = true 
             ;

     moveDir = new Vector3(Input.GetAxis(PlayerInput.Horizontal), 0f, Input.GetAxis(PlayerInput.Vertical));

     if(moveDir.sqrMagnitude > 1f) moveDir = moveDir.normalized;

     _motor.inputMoveDirection = _playerTransform.TransformDirection(moveDir);
     _motor.inputJump = Input.GetButtonDown(PlayerInput.Jump);

     _motor.movement.maxForwardSpeed = (walk) ? walkSpeed : runSpeed;
     _motor.movement.maxBackwardSpeed = _motor.movement.maxForwardSpeed;
     _motor.movement.maxSidewaysSpeed = (walk) ? walkStrafeSpeed : runStrafeSpeed;

     if(moveDir !=Vector3.zero) idleTimer = 0f;

     inAir = !_motor.grounded;
     grounded = !inAir;

     float currentAngle = _playerTransform.localRotation.eulerAngles.y;
     float delta = Mathf.Repeat((targetYRotation - currentAngle), 360f);
     if(delta > 180f) delta -= 360f;

     float newYRot = Mathf.MoveTowards(currentAngle, currentAngle + delta, idleTimer.deltatime * maxRotationSpeed);
     Vector3 newLocalRot = new Vector3(_playerTransform.localRotaion.eularAngles.x, newYRot, _playerTransform.localRotaion. eulerAngles.Z);
     _playerTransform.localRotation = Quaternion.Euler(newLocalRot);
 }

 #endregion

 #region Custom Methods
 private void GetUserInput()
 {
     aim = Input.GetButton (PlayerInput.Fire2);

     idleTimer += Time.deltaTime;

         walk = (!Input.GetButton(PlayerInput.Run) || moveDir == Vector3.zero || Input.GetAxis(PlayerInput.Vertical) < 0f);
 }
 #endregion
 }

}

Comment
Comments Locked · Show 2
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 gjf · Mar 18, 2015 at 08:07 AM 1
Share

because you haven't formatted all of your code it's impossible to see the offending line, but it's most likely because you haven't got a closing brace after this statement:

 if(!_motor.canControl)

that's line 55 in the code you've posted. depending on what you're code is supposed to be doing, it might need adding around line 85, or it could be line 60... that's a guess on my part - it's not my code ;)

avatar image Owen-Reynolds · Mar 18, 2015 at 02:42 PM 0
Share

Double-click the error to find the line. Read the message.

Suppose you were reading: "The best apples have a taste Private Area." The word "private" is unexpected. It looks like the sentence about apples isn't complete.

0 Replies

  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

getting udp package info inside unity (GlovePIE) 0 Answers

Doodle Jump game issue 1 Answer

Game not working properly 0 Answers

How to compare if two gameObjects are the same? 2 Answers

Can't see underneath terrain. How do I fix this? 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