Moira Willenov
Registered User
Join date: 1 Jul 2008
Posts: 15
|
11-03-2009 08:33
ok this is what i'm using to rot child prim torwards a target.. There is only one prob, it only rotates around the z axis. i cant seem to mod it so that it moves on all axis. can someone help me? here it is...
vector pos = llGetPos(); vector targetPos = llDetectedPos ( 0 ); float anglez = llAtan2(targetPos.y - pos.y, targetPos.x - pos.x); vector rootRot = llRot2Euler(llGetRootRotation()); rotation Rotation = llEuler2Rot ( < 0.0, 0.0, anglez - rootRot.z > ); llSetLocalRot ( Rotation );
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
11-03-2009 09:01
All you have to go on is a rotation between to vectors and that is not enough to give a single solution to your problem. Say the forward axis is rotated to fill your demands, then you can rotate the prim around the forward axis anyway and the forward axis is still in place. You must know one more parameter to have full control, say the Up axis must be pointed up. If you just want the forward axis to be turned from one direction to another, you can use this script(modify it for your local rotation): vector lookat; // coordinates of point to look at default { state_entry() { llSetRot( llRotBetween( < 1.0, 0.0, 0.0 >, llVecNorm(lookat-llGetPos()))); }
moving_end() { // refresh after move llSetRot( llRotBetween( < 1.0, 0.0, 0.0 >, llVecNorm(lookat-llGetPos()))); } }
What you are looking for may be this: vector pos = llGetPos(); vector targetPos = llDetectedPos ( 0 ); llSetLocalRot( llRotBetween( < 1.0, 0.0, 0.0 >, llVecNorm(targetPos-pos)));
If you want full control of the rotation use 'llAxesToRot' http://wiki.secondlife.com/wiki/LlAxes2Rot And don't forget to read the Visual Illustration under Tests
_____________________
From Studio Dora
|
Moira Willenov
Registered User
Join date: 1 Jul 2008
Posts: 15
|
ty. 
11-03-2009 10:56
tyvm for your help but i cant seem to get any of those examples to popint correctly along the x axis towrard a target. 
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
11-03-2009 12:36
When called in a child prim llGetPos() will get the local position in the linkset. If you want the global position make sure you use llGetRootPos() or llGetRootPos()+llGetPos()
_____________________
From Studio Dora
|