Skip to content

Instantly share code, notes, and snippets.

View GuestEG's full-sized avatar

Ilya "Guest" Plotkin GuestEG

  • Russia
View GitHub Profile
@GuestEG
GuestEG / gist:e3b82a584f691199da3dc50e839550c7
Created October 31, 2017 14:12
snapping to value on grid
public float snapValue = 0.5;
public float depth = 0;
void Update() {
float snapInverse = 1/snapValue;
float x, y, z;
// if snapValue = .5, x = 1.45 -> snapInverse = 2 -> x*2 => 2.90 -> round 2.90 => 3 -> 3/2 => 1.5