Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created July 13, 2016 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/ee5bb0e9d9ad24f3d6c61d4af5b3f85d to your computer and use it in GitHub Desktop.
Save flushpot1125/ee5bb0e9d9ad24f3d6c61d4af5b3f85d to your computer and use it in GitHub Desktop.
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);
}
}
}
@flushpot1125
Copy link
Author

This is a sample code for Cortana and Unity connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment