Created
June 13, 2018 11:45
-
-
Save SatoshiRobatoFujimoto/967eb35262d2a5e19226aec200fffaca to your computer and use it in GitHub Desktop.
HoloLens オブジェクト投げるスクリプト
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 System.Collections; | |
using System.Collections.Generic; | |
using HoloToolkit.Unity.InputModule; | |
using UnityEngine; | |
public class ThrowingObject : MonoBehaviour, IInputClickHandler | |
{ | |
public float thrust; | |
public GameObject obj; | |
// Use this for initialization | |
void Start() | |
{ | |
InputManager.Instance.AddGlobalListener(gameObject); | |
} | |
public void OnInputClicked(InputClickedEventData eventData) | |
{ | |
GameObject clone = GameObject.Instantiate(obj); | |
clone.transform.position = Camera.main.transform.TransformPoint(0.0f, 0.1f, 0.0f); | |
Rigidbody rb = clone.GetComponent<Rigidbody>(); | |
rb.AddForce(Camera.main.transform.forward * thrust); | |
rb.useGravity = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment