This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float AngleBetweenVector2(Vector2 vec1, Vector2 vec2) | |
{ | |
Vector2 diference = vec2 - vec1; | |
float sign = (vec2.y < vec1.y)? -1.0f : 1.0f; | |
return Vector2.Angle(Vector2.right, diference) * sign; | |
} | |
float cosAngleBetweenVector3(Vector3 vec1, Vector3, vec2) | |
{ | |
float dot = Vector3.Dot(vec1,vec2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a memory cgroup named 'mygroup', allowing $USER to change the parameters and run tasks in the cgroup. | |
sudo cgcreate -a $USER -t $USER -g memory:mygroup | |
# Set the memory limit to 10MB | |
echo 10000000 > /sys/fs/cgroup/memory/mygroup/memory.limit_in_bytes | |
# Run a program in the cgroup | |
cgexec -g memory:mygroup ls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//taken from http://answers.unity3d.com/questions/1097270/project-a-vector3-onto-a-plane-orthographically.html | |
//You simply project your vector onto the normal and subtract the result from your original vector. That will give you the projected vector on the plane. If you want to project a point to a plane you first need to calculate the relative vector from a point on that plane. | |
Vector3 planeOrigin; | |
Vector3 planeNormal; | |
Vector3 point; | |
Vector3 v = point - planeOrigin; | |
Vector3 d = Vector3.Project(v, planeNormal.normalized); | |
Vector3 projectedPoint = point - d; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//taken from https://github.com/razvanilin/Nebulae/blob/master/Assets/Scripts/CameraMovement.cs | |
using UnityEngine; | |
using System.Collections; | |
public class CameraMovement : MonoBehaviour { | |
public Transform target; | |
public float distance = 2.0f; | |
public float height; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//now supports missile acceleration! | |
Vector3 SlowDogCurve() | |
{ | |
min.Clear(); | |
var line = GetComponent<LineRenderer>(); | |
//find desired velocity vector | |
var Vt = target.GetComponent<Rigidbody>().velocity; | |
var Vm0 = rb.velocity; | |
var Pt0 = target.transform.position; | |
var Pm0 = transform.position; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://answers.unity3d.com/questions/353132/smoothdamp-causes-jitters.html | |
body.interpolation = RigidbodyInterpolation.Interpolate; | |
don't parent target to camera that follows it, especially if target or camera is physics driven | |
if target is physics drive, use fixedUpdate on camera |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ContextMenu("function")] | |
private void myfunction() | |
{ | |
//function can be called by right clicking on component and select function | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Timer { | |
public float StartTime; | |
public float Duration; | |
bool Idle; | |
public Timer(float d) | |
{ | |
Idle = false; | |
Duration = d; | |
StartTime = Time.time; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using System; | |
//data structure for hex grid | |
class HexLink | |
{ | |
public Hex link = null; | |
public bool river = false; | |
public HexLink(Hex h=null, bool r=false) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//define game | |
win condition: player with most coins | |
player has stats {powers, coins, hearts, mechs, buildings, enlistments} | |
player has x cards, each card with 2 actions {top row action, bottom row action} | |
player move in hex grid | |
player chooses one action card and perform up to two actions | |
nouns: tile, resource, mech, building, coin, power, heart, enlistment | |
verbs: move, build, deploy, upgrade, enlist, |
OlderNewer