Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
HoloLens オブジェクト投げるスクリプト
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()
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
You can’t perform that action at this time.