Skip to content

Instantly share code, notes, and snippets.

View moon-goon's full-sized avatar
🎯
Focusing

moongoon moon-goon

🎯
Focusing
  • Canada
View GitHub Profile
void Update () {
//Debug.Log(Input.GetAxis("Horizontal"));
transform.Translate(Input.GetAxis("Horizontal") * Time.deltaTime, 0f, Input.GetAxis("Vertical") * Time.deltaTime);
}
void OnCollisionEnter(Collision target) {
// create a gameobject (a cube for this demo) name it "enemy"
// and your argument(target) is setup so that object can be collided with
if (target.gameObject.name == "enemy") {
// Change the player's color to green when collide occurs
gameObject.GetComponent<Renderer>().material.color = Color.green;
}
}
void OnCollisionExit(Collision collisionInfo) {
// not calling collisionInfo at this time but we can get the additional information using
// for example: collisionInfo.transform.name
// change player's color to red when collision is ended (not touching each other)
gameObject.GetComponent<Renderer>().material.color = Color.red;
}
@moon-goon
moon-goon / endcode.js
Last active January 28, 2016 19:08
Javascript / Encode and Decode using customized Regex
var encode = "abcdefg !@#$%^&*()"
var decode = "zyxwvut";
var swapValue = {
a:"z",
b:"y",
c:"x",
d:"w",
e:"v",
f:"u",
public GameObject target;
void LateUpdate() {
transform.LookAt(target.transform);
}
public GameObject targetObj;
public float smooth = 1;
Vector3 offsetValue;
void Start() {
offsetValue = transform.position - targetObj.transform.position;
}
void LateUpdate() {
public GameObject targetObj;
private Vector3 offsetValue;
void Start() {
offsetValue = transform.position - targetObj.transform.position;
}
void Update() {
transform.position = targetObj.transform.position + offsetValue;
}
public GameObject targetObj;
public float rotateSpeed = 2;
Vector3 offsetValue;
void Start() {
offsetValue = targetObj.transform.position - transform.position;
}
void LateUpdate() {
@moon-goon
moon-goon / script.js
Created January 29, 2016 16:41
javascript entry point with jshint integration
/*jshint browser:true */
/*jshint devel:true */
(function() {
"use strict";
window.addEventListener('load', main);
function main(){
public Image healthBar;
public float maximumHealth = 100f;
public float currentHealth = 0f;
void Start() {
currentHealth = maximumHealth;
}
void Update() {