duck

simple rope interpolation

Jun 29th, 2011
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. float length = (dest.position-source.position);
  2.  
  3. for (int n=1; n < numBones-1; ++n) {
  4.  
  5.     float i = Mathf.InverseLerp(0,numBones,n);
  6.     float si = Mathf.SmoothStep(i);
  7.    
  8.     float sourceLine = source.position + source.forward * length * i;
  9.     float destLine = dest.position - dest.forward * length * (1-i);
  10.    
  11.     Vector3 pos = Vector3.Lerp( sourceLine, destLine, si);
  12.     Quaternion rot = Quaternion.Slerp( source.rotation, dest.rotation, si);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment