Skip to content

Instantly share code, notes, and snippets.

@Drenerdo
Created June 5, 2016 04:39
Show Gist options
  • Save Drenerdo/d7870575a60f64b93608cfb0ea672c87 to your computer and use it in GitHub Desktop.
Save Drenerdo/d7870575a60f64b93608cfb0ea672c87 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class ball : MonoBehaviour {
public bool lefthasball = false;
public bool righthasball = false;
public Transform leftball;
public Transform rightball;
private static ball singleton;
public static ball s {get {return singleton;}}
protected void Awake(){
singleton = this;
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter(Collision col) {
Debug.Log ("balled");
if (col.transform.name == "WristLeft" && !lefthasball){
Transform newball = (Transform)Instantiate (ObjectManager.s.ballprefab, new Vector3 (0, 0, 0), Quaternion.identity) as Transform;
Transform ballhandpos = col.transform.FindChild ("kinect_hand_3(Clone)").FindChild ("ball_place");
newball.parent = ballhandpos;
newball.localPosition = new Vector3 (0, 0, 0);
lefthasball = true;
leftball = newball;
leftball.localScale = new Vector3 (1f, 1f, 1f);
}
if (col.transform.name == "WristRight" && !righthasball) {
Transform newball = (Transform)Instantiate (ObjectManager.s.ballprefab, new Vector3 (0, 0, 0), Quaternion.identity) as Transform;
Transform ballhandpos = col.transform.FindChild ("kinect_hand_3(Clone)").FindChild ("ball_place");
newball.parent = ballhandpos;
newball.localPosition = new Vector3 (0, 0, 0);
righthasball = true;
rightball = newball;
rightball.localScale = new Vector3 (1f, 1f, 1f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment