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;
}
}
}
}
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.
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
Follow this Question
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