RandomCircleEdge
public static Vector2 RandomCircle(float radius) { float ang = Random.value * 360; return new Vector2(radius * Mathf.Sin(ang * Mathf.Deg2Rad), radius * Mathf.Cos(ang * Mathf.Deg2Rad)); }
let's talk about Bridgerton tea, my ask is open
Lint Roller? I Barely Know Her
macklin celebrini has autism

No title available
I'd rather be in outer space 🛸
noise dept.

No title available

gracie abrams
Sweet Seals For You, Always

PR's Tumblrdome
PUT YOUR BEARD IN MY MOUTH
sheepfilms
occasionally subtle
Claire Keane
cherry valley forever

@theartofmadeline
Fai_Ryy
Show & Tell
almost home
ojovivo
seen from United States

seen from United States

seen from United Kingdom
seen from Vietnam

seen from United States

seen from Bangladesh
seen from Romania

seen from Netherlands

seen from United States

seen from United States
seen from Maldives
seen from Italy

seen from Malaysia
seen from United States
seen from United States
seen from Malaysia

seen from United States
seen from Brazil
seen from Paraguay
seen from United States
@unitysnippets
RandomCircleEdge
public static Vector2 RandomCircle(float radius) { float ang = Random.value * 360; return new Vector2(radius * Mathf.Sin(ang * Mathf.Deg2Rad), radius * Mathf.Cos(ang * Mathf.Deg2Rad)); }
Got a few to post - maybe we should do one tip per post? Note these could be blindingly obvious or seem silly, but just stuff you didn't realize that...
Imgur is home to the web's most popular image content, curated in real time by a dedicated community through commenting, voting and sharing.
var width = 5; var height = 5; var searchWidth = 3; var searchHeight = 3; var startX = 2; var startY = Math.floor(0.5*(height-1)); var min = Math.min(searchWidth, searchHeight); var minSqr = min*min; var grid = new Array(width); for(var x = 0; x < width; x++){ grid[x] = new Array(height); } for(var y = 0; y < height; y++){ for(var x = 0; x < width; x++){ grid[x][y] = ""; } } var x = 0; var y = 0; var delta = [0, -1]; for (var i = 0; i<minSqr; i++) { //is a valid tile if ((-width/2 < x <= width/2) && (-searchHeight/2 < y <= searchHeight/2)) { if (startX+x>=0&&startX+x<width&&startY+y>=0&&startY+y<height) { console.debug('POINT', startX+x, startY+y); grid[startX+x][startY+y] = i; } } if (x === y || (x < 0 && x === -y) || (x > 0 && x === 1-y)){ // change direction delta = [-delta[1], delta[0]] } x += delta[0]; y += delta[1]; } grid[1][0] = "!"; console.table(grid);
Destroy All Children
public void DestroyAllChildren(GameObject parent){
foreach(Transform child in parent.transform) {
Destroy(child.gameObject);
}
}
Screen to World Position
public class ScreenPosition3D : MonoBehaviour {
public Camera cam;
public Vector2 screenPosition;
public float dispZPos = 1.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position = cam.ViewportToWorldPoint(new Vector3(screenPosition.x, screenPosition.y, dispZPos));
}
}
2d Angle
private float Angle (Vector2 pos1, Vector2 pos2) {
Vector2 from = pos2 - pos1;
Vector2 to = new Vector2(1, 0);
float result = Vector2.Angle( from, to );
Vector3 cross = Vector3.Cross( from, to );
if (cross.z > 0)
result = 360f - result;
return result;
}
FluidRect
public Rect FluidRect(float x, float y, float width, float height){ return new Rect(x*Screen.width, y*Screen.height, width*Screen.width, height*Screen.height); }
Enable Children
public void EnableChildren () {
foreach (Transform child in transform)
{
child.active = true;
}
}