Jump to content

Help: rotate physical object around its facing/forward axis


Restless Swords
 Share

You are about to reply to a thread that has been inactive for 2901 days.

Please take a moment to consider if this thread is worth bumping.

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.

 

Link to comment
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);    }}

 

Link to comment
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.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2901 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...