innula

Untitled

Feb 2nd, 2013
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. vector target;
  2. key targetKey;
  3.  
  4. vector vLin(vector x, vector y, float t){
  5. return x*(1-t) + y*t;
  6. }
  7. // Released into public domain. By Nexii Malthus.
  8. default
  9. {
  10. state_entry()
  11. {
  12. llSay(0, "Hello, Avatar!");
  13. }
  14.  
  15. touch_start(integer total_number)
  16. {
  17. llSensor("target","",ACTIVE|PASSIVE,20.0,PI);
  18. }
  19.  
  20. sensor(integer sensed){
  21. targetKey=llDetectedKey(0);
  22. vector vTarget=llList2Vector(llGetObjectDetails(targetKey,[OBJECT_POS]),0);
  23. vector vPos=llGetPos(); //object position
  24. float fDistance=llVecDist(<vTarget.x,vTarget.y,0>,<vPos.x,vPos.y,0>); // XY Distance, disregarding height differences.
  25. llRotLookAt(llRotBetween(<1,0,0>,llVecNorm(<fDistance,0,vTarget.z - vPos.z>)) * llRotBetween(<1,0,0>,llVecNorm(<vTarget.x - vPos.x,vTarget.y - vPos.y,0>)),1.0,0.1);
  26. vector v = vLin(vPos,vTarget,0.5);
  27. llSetPos(v);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment