Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class ControllerManager : MonoBehaviour {
- public Rigidbody BulletPrefab;
- public Transform BarrelEnd;
- public float MyForce;
- public float timer;
- public GameObject PlayerBullet;
- Animation otherAnimator;
- private Valve.VR.EVRButtonId triggerButton = Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger;
- private SteamVR_TrackedObject trackedObject;
- private SteamVR_Controller.Device device;
- void Start () {
- trackedObject = GetComponent<SteamVR_TrackedObject> ();
- timer = 0;
- }
- void Update () {
- timer += Time.deltaTime;
- device = SteamVR_Controller.Input ((int)trackedObject.index);
- if(device.GetPressDown(triggerButton))
- {
- if (timer > 2.0f) {
- device.TriggerHapticPulse (700);
- otherAnimator = PlayerBullet.GetComponent<Animation> ();
- Rigidbody bulletInstance;
- bulletInstance = Instantiate (BulletPrefab, BarrelEnd.position, BarrelEnd.rotation) as Rigidbody;
- bulletInstance.AddForce (BarrelEnd.forward * MyForce);
- timer = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment