1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
-
- using UnityEngine;
- using System.Collections;
- namespace Valve.VR.InteractionSystem
- {
-
- public class SpawnAndAttachAfterControllerIsTracking : MonoBehaviour
- {
- private Hand hand;
- public GameObject itemPrefab;
-
- void Start()
- {
- hand = GetComponentInParent<Hand>();
- }
-
- void Update()
- {
- if ( itemPrefab != null )
- {
- if (hand.isActive && hand.isPoseValid)
- {
- GameObject objectToAttach = GameObject.Instantiate(itemPrefab);
- objectToAttach.SetActive(true);
- hand.AttachObject(objectToAttach, GrabTypes.Scripted);
- hand.TriggerHapticPulse(800);
- Destroy(gameObject);
-
-
- objectToAttach.transform.localScale = itemPrefab.transform.localScale;
- }
- }
- }
- }
- }
|