Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

how to add force to a tapped instantiated cube ?

edited November 2016 in Questions And Answers

I followed this great tutorial to create cube prefabs successfully.

Then I tried to add a few lines to immediately add force to the cube, so that it should look like I tapped to shoot a cube. But the Addforce didn't work, the cubes created just keep free falling. I am using the transform.forward of the instantiated instance, this argument should be correct, I don't understand why it did not work.

Please take a look, is there any mistakes?
Thanks beforehand.

All I have modified was following, added no more than 10 lines to GestureRecognizer_TappedEvent() in the GestureManager.cs from Holotoolkit.

private void GestureRecognizer_TappedEvent(InteractionSourceKind source, int tapCount, Ray headRay) { //headRay.origin gives us the position that the HoloLens wearer is at. //headRay.direction gives us the direction that the HoloLens wearer is looking. //if we want to get the position 2m in front of the HoloLens, we can multiply the direction by 2, // and add it to the origin value, like the code below var direction = headRay.direction; var origin = headRay.origin; var position = origin + direction * 2.0f; Rigidbody cubeInstance; cubeInstance = Instantiate(CubePrefab, position, Quaternion.identity) as Rigidbody; cubeInstance.AddForce(cubeInstance.transform.forward * 1000); CalcFocusedObject(); OnTap(); }

Sign In or Register to comment.