Skip to content

Instantly share code, notes, and snippets.

View jgonzosan's full-sized avatar

Jonathan Gonzalez jgonzosan

View GitHub Profile
@jgonzosan
jgonzosan / SceneLoader
Created May 2, 2019 15:47
This simple script can be used for any UI buttons (or general scene loading) to load the first scene in the game (after the main menu), restart the current scene, or exit the game
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneLoader : MonoBehaviour
{
//this can be used to start the first level within your game (second scene in build settings)
public void StartLevel ()
@jgonzosan
jgonzosan / Camera Shake
Last active January 10, 2021 00:46
This script can be used to add shake to a camera in Unity. This is useful for explosions or erratic movements of the camera that can either be sustained or short.
using UnityEngine;
using System.Collections;
public class Shake : MonoBehaviour
{
public float shakeDuration = 0f;
public float shakeAmount = 0.7f;
public float decreaseFactor = 1.0f;
public bool soloStart;