UFPS Tips – Swimming

This tutorial covers setting up Trigger Volumes for a swimming effect.  This effect was created entirely by the VisionPunk team and I do not take credit for it.  I have also created a script to handle the image/camera effects.

The information can be found at the below site.
http://www.opsive.com/assets/UFPS/forum/index.php?p=/discussion/396/swimming-trigger#latest/p1

Water Effect Script

using UnityEngine;
using System.Collections;
using UnityStandardAssets.ImageEffects;//Need this namespace reference to be able to reference the ImageEffects

namespace red
{
 public class red_InWater : MonoBehaviour {

 //Below are just examples. Other options could be to turn on/off Fog, but I like ImamgeEffects better
 public BlurOptimized blurScript=null; //I Put this on the Weapon Camera so the weapon is blurred
 public ColorCorrectionCurves colorScript=null; //I Put this on the FPSCamera

 //Layer for the Player
 public LayerMask playerLayer = 1 << vp_Layer.LocalPlayer; // layer mask to check for
 vp_FPCamera m_camera=null;

 void OnTriggerEnter(Collider col)
 {
 //First check to see if whatever collided is in the layer mask. If not, return
 if((playerLayer.value & 1 << col.gameObject.layer)==0)
 return;
 m_camera=col.gameObject.GetComponentInChildren<vp_FPCamera>();
 TurnOn();
 }
 void OnTriggerExit(Collider col)
 {
 //First check to see if whatever collided is in the layer mask. If not, return
 if((playerLayer.value & 1 << col.gameObject.layer)==0)
 return;
 m_camera=col.gameObject.GetComponentInChildren<vp_FPCamera>();
 TurnOff();
 }

 void TurnOff()
 {
 //Do your specific stuff here to disable things
 blurScript=m_camera.GetComponentInChildren<BlurOptimized>();
 blurScript.enabled=false;
 colorScript=m_camera.GetComponentInChildren<ColorCorrectionCurves>();
 colorScript.enabled=false;
 }
 void TurnOn()
 {
 //Do your specific stuff here to enable things
 blurScript=m_camera.GetComponentInChildren<BlurOptimized>();
 blurScript.enabled=true;
 colorScript=m_camera.GetComponentInChildren<ColorCorrectionCurves>();
 colorScript.enabled=true;
 }
 }
}

HeaderWP

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s