mvaganov

InteractableParticleSystemObject.cs

Mar 7th, 2018
89
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class InteractableParticleSystemObject : VRTK.VRTK_InteractableObject {
  6.     public ParticleSystem ps;
  7.     public int triggerBurst = 50;
  8.  
  9.     void Start() {
  10.         if (ps == null) {
  11.             ps = GetComponent<ParticleSystem> ();
  12.             if (ps == null) {
  13.                 ps = GetComponentInChildren<ParticleSystem> ();
  14.             }
  15.         }
  16.         ps.Stop ();
  17.         this.isGrabbable = true;
  18.         this.isUsable = true;
  19.     }
  20.  
  21.     public override void StartUsing(VRTK.VRTK_InteractUse usingObject) {
  22.         base.StartUsing(usingObject);
  23.         ps.Play ();
  24.         ps.Emit (triggerBurst);
  25.     }
  26.  
  27.     public override void StopUsing(VRTK.VRTK_InteractUse usingObject) {
  28.         base.StopUsing(usingObject);
  29.         ps.Stop ();
  30.     }
  31.  
  32.     public virtual void Grabbed(VRTK.VRTK_InteractGrab currentGrabbingObject = null) {
  33.         base.Grabbed (currentGrabbingObject);
  34.         VRTK.VRTK_InteractUse iu = currentGrabbingObject.gameObject.GetComponent<VRTK.VRTK_InteractUse> ();
  35.         if (iu == null) {
  36.             iu = currentGrabbingObject.gameObject.AddComponent<VRTK.VRTK_InteractUse> ();
  37.         }
  38.     }
  39. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×