Created
July 13, 2016 13:01
-
-
Save flushpot1125/ee5bb0e9d9ad24f3d6c61d4af5b3f85d to your computer and use it in GitHub Desktop.
This file contains 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 UnityEngine; | |
using System.Collections; | |
public class InvokedByCortana : MonoBehaviour { | |
public delegate void OnEvent(object arg); | |
public OnEvent onEvent = null; | |
public GameObject flarePrefab; | |
public GameObject flareGeneratePointPrefab; | |
public GameObject TargetPrefab; | |
public GameObject TargetGeneratePointPrefab; | |
void Update() { | |
/*for debug only*/ | |
if (Input.GetKeyDown(KeyCode.E)) { | |
generateFlare(); | |
} | |
if (Input.GetKeyDown(KeyCode.F)) { | |
proceedFlare(); | |
} | |
/**/ | |
} | |
public void generateFlare() { | |
GameObject flareObj = GameObject.FindGameObjectWithTag("flare"); | |
if (flareObj == null) { | |
flareObj = Instantiate(flarePrefab, flareGeneratePointPrefab.transform.position, Quaternion.identity) as GameObject; | |
flareObj.tag = "flare"; | |
} | |
GameObject TargetObj = GameObject.Find("Target"); | |
if(TargetObj == null) { | |
TargetObj = Instantiate(TargetPrefab, TargetGeneratePointPrefab.transform.position, Quaternion.identity) as GameObject; | |
TargetObj.name = "Target"; | |
} | |
} | |
public void proceedFlare() { | |
GameObject flareObj = GameObject.FindGameObjectWithTag("flare"); | |
if (flareObj != null) { | |
flareObj.GetComponent<Rigidbody>().AddForce(TargetGeneratePointPrefab.transform.position*10, ForceMode.Acceleration); | |
// flareObj.transform.Translate(TargetGeneratePointPrefab.transform.position); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a sample code for Cortana and Unity connection.