Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@flushpot1125 flushpot1125 commented Jul 13, 2016

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