Advertisement
Jasdoge

Sinusoidal KFM

Jul 20th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. goto(){
  2.     // Start position
  3.     SPOS = llGetPos();
  4.    
  5.     // End position at llGetOwner position
  6.     vector to = prPos(llGetOwner());
  7.    
  8.     // Meters above start position to go
  9.     float above = 3;
  10.    
  11.     // Total time of animations
  12.     float total_time = 3;
  13.  
  14.     // Nr of keyframes
  15.     integer steps = 10;
  16.    
  17.     // Where to go in local coordinates
  18.     vector travel = to-SPOS;
  19.    
  20.    
  21.     integer i; list out = [];
  22.    
  23.     // Previous frame position
  24.     vector pre = SPOS;
  25.     for(i=1; i<=steps; i++){
  26.        
  27.         // Where to go in a straight line
  28.         vector v = travel*((float)i/steps);
  29.        
  30.         // Additinal Z to make it curve there
  31.         float z = llSin(PI*(float)i/steps)*above;
  32.        
  33.         // Global position to go to this frame
  34.         vector p = (SPOS+v+<0,0,z>);
  35.  
  36.         // add
  37.         out+= [p-pre, total_time/steps];
  38.        
  39.         // Save previous frame position
  40.         pre = p;
  41.        
  42.     }
  43.    
  44.     // Begin
  45.     llSetKeyframedMotion(out, [KFM_DATA, KFM_TRANSLATION]);
  46.    
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement