Spawn Object in vr player hand as grabbed. Release button to let go of the object?,Spawn game object from pool into VR hand
I am trying to make it so when the player presses the b/y button on the VR controller a ball spawns in their hand and then they have the ability to throw the ball by releasing the button. But as of now the ball falls to the ground but is still influenced by the hand parent. here is what I have now.
// 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?
,
Your answer
Follow this Question
Related Questions
Steam VR, spawn object in hand as grabbed? (Solved!) 0 Answers
When I scale parent, it scales child, how to stop? 0 Answers
Make projectile go to the object pooler when it collides 1 Answer
How do I check if SteamVR is installed and Vive is connected? 2 Answers
Particle Systems. Stick inside pooled objects or pool them separately. 1 Answer