Question by
SEIFFFFFFFF · Nov 21, 2016 at 12:02 PM ·
errorpublicprivateunexpected-symbolcs1525
how to fix error CS1525: Unexpected symbol `public' and 'private'
Here are the scripts:
PlayerMotor:
public class PlayerMotor : MonoBehaviour
{
private CharacterController controller;
private Vector3 moveVector;
private float speed = 10.0f;
private float verticalVelocity = 0.0f;
private float gravity = 5.0f;
private float animationDuration = 2.0f;
// Use this for initialization
void Start () {
controller = GetComponent<CharacterController> ();
}
// Update is called once per frame
void Update () {
if (Time.time < animationDuration)
{
controller.Move (Vector3.forward * speed * Time.deltaTime);
return;
}
moveVector = Vector3.zero;
if (controller.isGrounded)
{
verticalVelocity = -0.5f;
}
else
{
verticalVelocity -= gravity * Time.deltaTime;
}
// X - Left and Right
moveVector.x = Input.GetAxisRaw("Horizontal") * speed;
// Y - Up and Down
moveVector.y = verticalVelocity;
// Z - Forward and Backward
moveVector.z = speed;
controller.Move (moveVector * Time.deltaTime);
public void SetSpeed(int modifier)
{
speed = 5.0f + modifier;
}
}
Score:
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour
{
private float score = 0.0f;
private int difficultyLevel = 1
**ERROR --> **private int maxDifficultyLevel = 10;
private int scoreToNextLevel = 10;
public Text scoreText;
// Update is called once per frame
void Update () {
if (score >= scoreToNextLevel)
LevelUp ();
score += Time.deltaTime * difficultyLevel;
scoreText.text = ((int)score).ToString ();
}
void LevelUp()
{
if (difficulityLevel == maxDifficultyLevel)
return;
scoreToNextLevel *= 2;
difficultyLevel++;
GetComponent<PlayerMotor> ().SetSpeed (difficultyLevel);
}
}
Comment
You're missing a semicolon after your
private int difficultyLevel = 1
Using $$anonymous$$ono it clearly highlights every line and every error you make. read the error, check the syntax which in most cases is wrong and correct it. $$anonymous$$issing ; and the kind are basic in program$$anonymous$$g so learning the language better is probably of more use than asking for code repair