Skip to content

Instantly share code, notes, and snippets.

View JakeLunn's full-sized avatar
🏠
Working from home

Jake Lunn JakeLunn

🏠
Working from home
View GitHub Profile
@JakeLunn
JakeLunn / projectile-motion-angle-required-to-hit-xyz.cs
Last active April 23, 2023 18:47
Unity, Projectile Motion, Angle Required to Hit Coordinate (X, Y, Z)
public static class PhysicsCalculator
{
// https://en.wikipedia.org/wiki/Projectile_motion#Angle_%CE%B8_required_to_hit_coordinate_(x,_y)
public static float CalculateAngleToHitXYZ(Vector3 from, Vector3 to, float v, float g)
{
g = Mathf.Abs(g); // According to the wikipedia article, g is acceleration due to gravity and is |g|
Vector3 s = (to - from); // Non-normalized so that we only get an angle if the velocity is enough to reach target.
float x = new Vector3(s.x, 0, s.z).magnitude;
float y = s.y;
// ==UserScript==
// @name @chaoticvibing Twitter Blue Clown - twitter.com
// @namespace Violentmonkey Scripts
// @match *://*.twitter.com/*
// @grant none
// @version 1.2.2clown
// @author @chaoticvibing - GH @busybox11
// @description 11/9/2022, 11:45:28 PM
// @updateURL https://gist.githubusercontent.com/busybox11/270a9ca89a26c79f467f214761303242/raw/twitterblue-nerd.js
// @downloadURL https://gist.githubusercontent.com/busybox11/270a9ca89a26c79f467f214761303242/raw/twitterblue-nerd.js