Dashiell Slade
Registered User
Join date: 14 Jul 2007
Posts: 15
|
11-27-2009 09:30
I am hoping someone can provide a function so that I won't need revisit trigonometry to re-invent this wheel. When a child prim executes llLookAt, it rotates the whole object. I want the parent to remain stationary.
Imagine a circle in the XY plane (flat cylinder and parent/root) with 12 linked child cones evenly space on the circle perimeter. Now imagine a ball positioned on the Z-axis over the center of the circle at an arbitrary height above it. I want ALL of the cones to point at that ball.
If these child cones were not linked, then llLookAt would work great, but since they ARE linked I assume I will be using llSetLocalRot. So what I want is the llLookAt equivalent for linked prims.
Thanks, Dash
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
11-27-2009 10:00
The following script has an approach you may be able to use, just substitute 'llSetRot' with 'llSetLocalRot' 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()))); } }
You may need to replace 'llGetPos' with 'llGetLocalPos'. That would depend on how you get the 'lookat' vector. Note: < 1.0, 0.0, 0.0 > indicates that X is forward. You can use < 0.0, 0.0, 1.0 > if you want Z as forward and similar for Y forward. Happy scripting 
_____________________
From Studio Dora
|
Dashiell Slade
Registered User
Join date: 14 Jul 2007
Posts: 15
|
11-27-2009 11:01
/me embraces the elegance of a simple solution and bows to Dora's wisdom 
|