Question by
22ecvvw · Feb 05, 2017 at 08:39 AM ·
error messagevoid
Unexpected symbol `void'
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraShake : MonoBehaviour
{
public float ShakeTimer = 1.0f;
public float ShakeAmount = 1.0f;
private bool isShaking;
private Vector3 startPosition;
private float currentShakeTimer;
}
// Use this for initialization
void Start()
{
startPosition = transform.position;
isShaking = false;
}
// Update is called once per frame
void Update()
{
if (other.tag == "Player")
{
ShakeCamera();
}
if (currentShakeTimer > 0)
{
var shakePos = Random.insideUnitCircle * ShakeAmount;
transform.position = new Vector3(startPosition.x + shakePos.x, startPosition.y + shakePos.y, startPosition.z);
currentShakeTimer -= Time.deltaTime;
}
else if(isShaking)
{
if (transform.position != startPosition)
{
transform.position = startPosition;
}
isShaking = false;
}
}
public void ShakeCamera()
{
isShaking = true;
currentShakeTimer = ShakeTimer;
}
Comment
Any ideas? Unity says Unexpected symbol `void'. I've been looking for a few hours now and i can't find out why its showing. Any help is greatly appreciated
Answer by Chikari · Feb 05, 2017 at 10:17 AM
In line 15, remove the "}". I assume you are closing your class block there. The function after it is unexpected as it is not within a class. So the function's keyword "void" is unexpected.
Your answer
Follow this Question
Related Questions
Void error 1 Answer
I need someone to help me: error CS1525: Unexpected symbol `void' 0 Answers
key word void cannot be used in this context 1 Answer
unexpected void error 1 Answer
Hi, Unexpected symbol at end of file. 0 Answers