daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Oct 14th, 2014 307 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         Vector3 GetCollisionSimple(Vector3 cameraOptPos, float radius)
  2.         {
  3.                 float farEnough = 1;
  4.        
  5.                 RaycastHit occHit;
  6.                 Vector3 origin = charHead.position;
  7.                 Vector3 occRay = origin - cameraOptPos;
  8.                 float dt = Vector3.Dot(transform.forward, occRay);
  9.                 if (dt < 0) occRay *= -1;
  10.                
  11.                 if (Physics.SphereCast(origin, radius, occRay.normalized, out occHit, farEnough, mask))
  12.                 {
  13.                         origin = origin + occRay.normalized * occHit.distance;
  14.                 }
  15.                 else
  16.                 {
  17.                         origin += occRay.normalized * farEnough;
  18.                 }
  19.                
  20.                 occRay = origin - cameraOptPos;
  21.                 if (Physics.SphereCast(origin, radius, -occRay.normalized, out occHit, occRay.magnitude, mask))
  22.                 {
  23.                         return occHit.point + occHit.normal * radius;
  24.                 }
  25.                 else
  26.                 {
  27.                         return cameraOptPos;
  28.                 }
  29.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top