Created
March 10, 2016 06:34
-
-
Save robertcedwards/a1e50c571e555ee168c3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class DynamicDOF : MonoBehaviour { | |
public Transform Origin; | |
public Transform target; | |
public DepthOfField34 DOF34; | |
void Update () { | |
Ray ray = new Ray(Origin.position, Origin.forward); | |
RaycastHit hit = new RaycastHit (); | |
if (Physics.Raycast (ray, out hit, Mathf.Infinity)) | |
{ | |
DOF34.objectFocus = target; | |
target.transform.position = hit.point; | |
} | |
else | |
{ | |
DOF34.objectFocus = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment