diff Orchestland/Assets/Scripts/Shot.cs @ 1:f7675884f2a1

Add Orchestland project
author Daiki OYAKAWA <e135764@ie.u-ryukyu.ac.jp>
date Fri, 17 Jul 2015 23:09:20 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Orchestland/Assets/Scripts/Shot.cs	Fri Jul 17 23:09:20 2015 +0900
@@ -0,0 +1,30 @@
+using UnityEngine;
+using System.Collections;
+
+public class Shot : MonoBehaviour {
+	public HandController hand_controller;
+	public GameObject bullet_prefab;
+
+	int time = 0;
+	// Use this for initialization
+	void Start () {
+	
+	}
+	
+	// Update is called once per frame
+	void Update () {
+		time++;
+		if (time > 60) {
+			time = 0;
+			HandModel[] hands = hand_controller.GetAllPhysicsHands();
+			foreach(HandModel hand in hands){
+				FingerModel[] fingers = hand.fingers;
+				foreach(FingerModel finger in fingers){
+					GameObject bullet = (GameObject)Instantiate(bullet_prefab);
+					bullet.transform.position = finger.bones[3].position + finger.bones[3].forward  * 0.5f;
+					bullet.GetComponent<Rigidbody>().velocity = finger.bones[3].forward * 5.0f;
+				}
+			}
+		}
+	}
+}