Skip to content

Instantly share code, notes, and snippets.

@TheCuttlefish
TheCuttlefish / GameStates.cs
Created March 8, 2021 13:36
Saving object data (static class)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class GameStates
{
public static bool BOX_ONE_IS_ACTIVE = true;
public static bool BOX_TWO_IS_ACTIVE = true;
public static bool BOX_THREE_IS_ACTIVE = true;
@TheCuttlefish
TheCuttlefish / LSystem.cs
Created February 19, 2021 12:18
L-system with colour /size/ rotation variation
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LSystem : MonoBehaviour
{
[System.Serializable]
@TheCuttlefish
TheCuttlefish / QuickPlayer.cs
Created February 2, 2021 13:11
Jumping on walls (platformer movement)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuickPlayer : MonoBehaviour
{
Rigidbody2D rb;
float xInput;
bool isGrounded;
@TheCuttlefish
TheCuttlefish / Bar.cs
Created January 28, 2021 16:38
Bar functionality
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bar : MonoBehaviour
{
public float fr = 1;
float climbValue;
float climbItensity = 1;
@TheCuttlefish
TheCuttlefish / Player.cs
Created January 14, 2021 14:57
Player Movement + Climbing
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
float speedX = 10f;
bool isClimbing = false;
float inputX;
@TheCuttlefish
TheCuttlefish / RandomColour.cs
Created December 14, 2020 16:57
Setting random Colour + Destroying objects
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomColour : MonoBehaviour
{
public int randomValue;
public float randomTimerValue;
public float randomDestoyValue;
@TheCuttlefish
TheCuttlefish / PlaySoundOnCollision.cs
Created December 11, 2020 13:31
Play sound on collision + change colour based on velocity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlaySoundOnCollision : MonoBehaviour
{
public AudioSource mySound;
public Rigidbody2D rb;
float velocityMag;
public Gradient myColour;
@TheCuttlefish
TheCuttlefish / Player.cs
Last active December 10, 2020 13:04
Hook mechanic
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
#region Variables
//movement + jump
@TheCuttlefish
TheCuttlefish / FollowCursor.cs
Created November 12, 2020 16:29
Follow cursor with physics
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FollowCursor : MonoBehaviour
{
Vector3 offset = new Vector3(0, 0, 10);
Rigidbody2D rb;
Vector2 cursorPos;
@TheCuttlefish
TheCuttlefish / ButtonScript.cs
Created November 11, 2020 17:09
On colour click move objects
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonScript : MonoBehaviour
{
public int myColour;
public GameObject player;
private void Start()