Skip to content

Instantly share code, notes, and snippets.

View whoisryosuke's full-sized avatar
👾
Going deep with game development

Ryosuke whoisryosuke

👾
Going deep with game development
View GitHub Profile
@whoisryosuke
whoisryosuke / fetch-post-request.js
Created November 29, 2021 08:35
JS - Fetch POST request as async function
(async () => {
const rawResponse = await fetch('https://httpbin.org/post', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({a: 1, b: 'Textual content'})
});
const content = await rawResponse.json();
@whoisryosuke
whoisryosuke / gist:3c482e593dee25e2b9d52f0f850b91ba
Created November 22, 2021 19:44 — forked from kany/gist:3714996
Git Repo changes ssh fingerprint - how to update your known_hosts file
1) Open known_hosts file and look for the invalid host
nano ~/.ssh/known_hosts
2) Remove the line that has the invalid host. Should be the same host in your .git/config of your repo
ssh-keygen -R [dev.blahblah.com]:1234
3) Pull from repo
git pull
4) You should see something similar to this. Answer 'yes' when asked.
@whoisryosuke
whoisryosuke / MouseLook.cs
Last active November 18, 2021 22:24
Unity - Basic 3D/FPS Character and Camera Movement + Jumping - based on Brackeyes video: https://www.youtube.com/watch?v=_QajrabyTJc
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
private bool mouseLock = true;
public float mouseSensitivity = 100f;
public Transform playerBody;
@whoisryosuke
whoisryosuke / PointerExample.cs
Created November 18, 2021 22:15
Unity - Detect input on canvas elements using EventSystem event interfaces (e.g. IPointerClickHandler) -- via: http://answers.unity.com/answers/1095070/view.html
using UnityEngine;
using UnityEngine.EventSystems; // 1
public class PointerExample : MonoBehaviour
, IPointerClickHandler // 2
, IDragHandler
, IPointerEnterHandler
, IPointerExitHandler
// ... And many more available!
{
@whoisryosuke
whoisryosuke / CheckClicks.cs
Created November 18, 2021 22:13
Unity - Detect click on canvas using graphic raycaster -- via: http://answers.unity.com/answers/1526703/view.html
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class CheckClicks : MonoBehaviour
{
// Normal raycasts do not work on UI elements, they require a special kind
GraphicRaycaster raycaster;
@whoisryosuke
whoisryosuke / PlayerLocomotionController.cs
Last active October 12, 2021 00:27
Unity - 3D Player Movement using Unity's Player Input package - via: https://www.youtube.com/watch?v=537B1kJp9YQ
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
// Handles actual movement of character + triggering things like animation
// This game has a "shooting mode" which is activated by Left Shift
// So you'll see shooting logic as well
public class PlayerLocomotionController : MonoBehaviour
@whoisryosuke
whoisryosuke / triangle.p8
Created October 6, 2021 00:16 — forked from Enichan/triangle.p8
Subpixel accurate triangle rasterizer prototype for Pico 8
pico-8 cartridge // http://www.pico-8.com
version 18
__lua__
--[[function spline(x0,y0,x1,y1,c)
local dx = x1 - x0
local dy = y1 - y0
local step = dx/dy
local x = x0 - (y0 % 1) * step
local y = flr(y0)
@whoisryosuke
whoisryosuke / change-to-main.sh
Created August 25, 2021 16:59
Git - Set default branch as main when creating new git repos (`git init`). As of Git 2.28 (released 27th July 2020), you can now configure the name of the branch created when you init a new repository. https://superuser.com/a/1572156
git config --global init.defaultBranch main
@whoisryosuke
whoisryosuke / FlyCamera.cs
Created August 24, 2021 23:37 — forked from gunderson/FlyCamera.cs
Unity Script to give camera WASD + mouse control
using UnityEngine;
using System.Collections;
public class FlyCamera : MonoBehaviour {
/*
Writen by Windexglow 11-13-10. Use it, edit it, steal it I don't care.
Converted to C# 27-02-13 - no credit wanted.
Simple flycam I made, since I couldn't find any others made public.
Made simple to use (drag and drop, done) for regular keyboard layout
@whoisryosuke
whoisryosuke / PlayerControllerFPS.prefab
Created August 23, 2021 23:33
Unity - Default player movement provided by Unity in some templates.
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &738646681595172696
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component: