Jump to content
Sign in to follow this  
Restless Swords

Help: rotate physical object around its facing/forward axis

Recommended Posts

I have a physical object (so cannot use llSetRot), and need to keep it facing in the same direction, but need to rotate it 90 degrees around that forward axis without changing its forward direction (so dont think i can use llRotLookAt). 

- think of an arrow in flight, and I need to turn the shaft so the feathers rotate 90 degrees)

I must have celebrated to much yesterday, this SHOULD be easy, but I just cant get it to work.

 

Share this post


Link to post
Share on other sites

It looks as if it should be possible, and 

      vector vPosTarget = llGetPos()+<0.0, 1.0, 0.0> * llGetRot();      llRotLookAt( llRotBetween( <0.0,0.0,1.0>, llVecNorm( vPosTarget - llGetPos() ) ), 1.0, 0.4 );

seems to work when the object starts at ZERO_ROTATION, but I can't get it work otherwise.

I vaguely remember there was a routine in the old Lsl Wiki that did this but the old LSL Wiki is offline at the mioment -- not permanently I hope.

I agree with Rolig -- llTargetOmega might be the best solution.

ETA:   I haven't tested this, but it looks as if it's worth trying (I suspect it's what I remember seeing in the LSL wiki): http://www.outworldz.com/cgi/freescripts.plx?ID=484

ETA 2:

I have now had time to test it, and a slightly modified version of the script at the link above seems to do the trick:

vector AXIS_LEFT = <0,1,0>;//slight modification of a user function originally// Created by Ope Rand, modified by Christopher Omegarotation getRotToPointAxisAt(vector axis, vector target) {        return llGetRot() * llRotBetween(axis * llGetRot(), target-llGetPos());}// Strength and damping are values used to control how llRotLookAt and llLookAt move, these values are tunable.float strength = 1.0;float damping = 1.0;default {    touch_start(integer num_detected) {                      vector vTarget = llGetPos() + <0.0,0.0,-1.0> *llGetRot();        llRotLookAt(getRotToPointAxisAt(AXIS_LEFT, vTarget), strength, damping);    }}

 

Share this post


Link to post
Share on other sites

Thx Innjula, i will give it a serious try and test.

 

PS: I know about llTargetOmega , and use it in other places and ways, but it is client side and has to many inconsistencies.

 

Share this post


Link to post
Share on other sites

I think you'll find that physical llTargetOmega is server-side. Of course, that also means it lacks some of the magic of non-physical llTargetOmega, so it will spew object updates, etc., but depending on details it may be simpler to use.

Share this post


Link to post
Share on other sites

If the OP wants to make the arrow spin continuously as it flies, llTargetOmega is the best way to go.  It works quite well on physical objects, where the motion is server side.  llLookAt and llRotLookAt are better suited for helping to keep the arrow's long axis pointed toward a target, but that's a matter of making continuous rotational adjustments around the arrow's other two axes rather than spinning around the long axis.  As I read the OP's description, that's not the "rotation" he's interested in.  I am puzzled about the relevance of "90 degrees," though.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...