mirror of
https://github.com/imperialsushi/gutterball-3.git
synced 2025-06-15 05:07:42 +00:00
38 lines
924 B
C#
38 lines
924 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CameraShake : MonoBehaviour
|
|
{
|
|
public Transform cam;
|
|
private GameManager gameManager;
|
|
private float shakeHit;
|
|
|
|
// Use this for initialization
|
|
void Start()
|
|
{
|
|
gameManager = GameObject.FindObjectOfType<GameManager>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (shakeHit > 0)
|
|
{
|
|
shakeHit -= Time.deltaTime * 10;
|
|
}
|
|
else if (shakeHit < 0)
|
|
{
|
|
shakeHit = 0;
|
|
}
|
|
transform.position = new Vector3(cam.position.x + Random.Range(-shakeHit, shakeHit), cam.position.y + Random.Range(-shakeHit, shakeHit), cam.position.z + Random.Range(-shakeHit, shakeHit));
|
|
}
|
|
|
|
public void Shake(float setShake)
|
|
{
|
|
if (GameManager.isShake)
|
|
{
|
|
shakeHit += setShake;
|
|
}
|
|
}
|
|
}
|