Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Apr 02, 2021 at 01:57 AM by Light_S for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Light_S · Apr 01, 2021 at 09:43 PM · steamparentingpooling

Steam VR, spawn object in hand as grabbed? (Solved!)

Trying to make it so when the player presses either B or Y on the controller a ball will spawn in their respective hand. And when the player releases the ball it will be thrown/ detach. Right now the ball just falls down upon spawning but is still influenced by the hand as a parent. Here is what I have so far:

 // a reference to the action
     public SteamVR_Action_Boolean SpawnBallFromPool;
     // a reference to the hands
     public SteamVR_Input_Sources handTypeRight;
     public SteamVR_Input_Sources handTypeLeft;
     public GameObject handRight;
     public GameObject handLeft;
     void Start()
     {
         SpawnBallFromPool.AddOnStateDownListener(TriggerDown, handTypeRight);
         SpawnBallFromPool.AddOnStateUpListener(TriggerUp, handTypeRight);
         SpawnBallFromPool.AddOnStateDownListener(TriggerDown, handTypeLeft);
         SpawnBallFromPool.AddOnStateUpListener(TriggerUp, handTypeLeft);
     }
 
     // For releasing the ball to be thrown.
     public void TriggerUp(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
     {
         Debug.Log("Trigger is up");
         GameObject Ball = ObjectPooler.SharedInstance.GetPooledObject();
         Ball.transform.parent = null;
     }
 
     // Summons ball in hand on button press down.
     public void TriggerDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
     {
         Debug.Log("Trigger is down");
         GameObject Ball = ObjectPooler.SharedInstance.GetPooledObject();
         if (Ball != null)
         {
             Ball.transform.position = handRight.transform.position;
             Ball.transform.rotation = handRight.transform.rotation;
             Ball.transform.parent = handRight.transform;
             Ball.SetActive(true);
         }
     }

Any tips?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image olas72 · Aug 04, 2021 at 02:10 AM 0
Share

What was your solution for this?

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

161 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Spawn Object in vr player hand as grabbed. Release button to let go of the object?,Spawn game object from pool into VR hand 0 Answers

Can someone post a generic object pool script? 4 Answers

How can I fix my object pool to continue after original pool is exhausted? 0 Answers

GameObjects can't be moved after being the Main Camera's Child 0 Answers

How to get parent with component on collision? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges