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;
}
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
– 22ecvvwAs i stated in my question, i'm very new to coroutines and as such my question could be badly phrased. I'm just looking for ways to optimize it. Hadn't thought of slowing the update rate, that might be a good idea. i don't need it to update each frame.
– MarcWerk