- Home /
Question by
KUFgoddess · Jan 24, 2017 at 07:42 AM ·
lerpimage effectslerping
How to lerp DepthOfField Depreciated 's values.
Made an aim down sight script now I'd like to be able to control the values and have it lerp or slerp smoothly (not sure if thats the right term) between two values on Focal Distance and / or Focal Size. What happens at the moment is it only toggles the image effect on or off but i'd like to control the focal Distance or Focal Size when I press Control on the keyboard. I feel like its something along the lines of altering this Camera.main.GetComponent().enabled = true; since I see it referencing the area I want to be affected. All guidance is greatly appreciated. Oh when you aim down sights in call of duty it sort of has the same effect I'm trying to achieve if that helps anyone out.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.ImageEffects;
public class ADS : MonoBehaviour {
public Vector3 aimDownSight;
public Vector3 hipFire;
public float aimSpeed = 5;
public DepthOfFieldDeprecated depthofField;
// Use this for initialization
void Start () {
Camera.main.GetComponent<DepthOfFieldDeprecated>().enabled = false;
}
// Update is called once per frame
void Update () {
if(Input.GetButtonDown("Fire2"))
{
transform.localPosition = Vector3.Slerp(transform.localPosition, aimDownSight,aimSpeed * Time.deltaTime);
Camera.main.GetComponent<DepthOfFieldDeprecated>().enabled = true;
}
if(Input.GetButtonUp("Fire2"))
{
transform.localPosition = hipFire;
Camera.main.GetComponent<DepthOfFieldDeprecated>().enabled = false;
}
}
}
Comment