Skip to content

Instantly share code, notes, and snippets.

@robertcedwards
Created March 10, 2016 06:34
Show Gist options
  • Save robertcedwards/a1e50c571e555ee168c3 to your computer and use it in GitHub Desktop.
Save robertcedwards/a1e50c571e555ee168c3 to your computer and use it in GitHub Desktop.
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