moving a child prim on its own axis
|
|
Aloah Oh
Registered User
Join date: 2 Jan 2008
Posts: 4
|
12-22-2008 02:38
Sorry if this has been covered before but I couldn't find it.
I want to make child prims that move on their own axis (in this case y axis), and not that of the sim or the parent. i.e 5 objects all with their y axis aligned with the radii of a sphere (the parent), will all move in and out from the centre of the sphere, whatever the spheres orientation. I am using llSetPos to move.
I am befuddled by the rotation thingy bit
p.s. i have tried this suggestion-- llSetPos(( llGetPos() + <0,1,0> ) / llGetRot());
any other ideas please.
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
12-22-2008 05:40
float x=distance_to_move; ... llSetPos( x*llRot2Left( llGetLocalRot())); or llSetPos( x*llRot2Left( llGetRot())); I am not sure about the GetRot. Anyway it should work in a child prim 
_____________________
From Studio Dora
|
|
Aloah Oh
Registered User
Join date: 2 Jan 2008
Posts: 4
|
not there yet
12-22-2008 07:38
Thanks - using llGetRot moves it on the region co-ordinates and using llGetLocalRot does something slightly unpredictable but the linked prim is not yet moving on its own y axis.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
12-22-2008 07:44
Using llGetLocalPos() and llGetLocalRot() instead of llGetPos() and llGetRot() should work. Oh, but you want to MULTIPLY by the rotation, not divide by it. A rotation transforms from a vector in the local coordinate frame (e.g. <0,1,0>  to one in the (more) global one (in this case from the prim's coordinates to the root prim's).
|
|
Aloah Oh
Registered User
Join date: 2 Jan 2008
Posts: 4
|
12-22-2008 09:04
llSetPos(( llGetLocalPos() + <0,0,.1> ) * llGetLocalRot());
only seems to work if the parent and child prim are rotated in the same direction. If either is turned then the child does not follow its own axis - its hard to see exactly what it does follow!
Also the distance it moves seems pretty random.
|
|
Alisha Matova
Too Old; Do Not Want!
Join date: 8 Mar 2007
Posts: 583
|
12-22-2008 09:34
Yay Rotations are fun!! Not..
Disreguard... Totally wrong thread.. Sorry
Good luck though= )
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
12-22-2008 16:12
From: Aloah Oh Thanks - using llGetRot moves it on the region co-ordinates and using llGetLocalRot does something slightly unpredictable but the linked prim is not yet moving on its own y axis. You obviously did not make the effort to test it, but I have now: // Studio Dora: move child on child's axis script, Dora Gustafson d.2008
float X = 1.0; vector locpos;
default { state_entry() { locpos = llGetLocalPos(); llSetPos( locpos + X*llRot2Left( llGetLocalRot())); }
touch_start(integer total_number) { state back; } }
state back { state_entry() { llSetPos(locpos); }
touch_start(integer total_number) { state default; } }
This script works like a charm when the Y axis is placed on a sphere radius. Only change to my first suggestion is an added offset obtained with llGetLocalPos(); (the script is placed in the child prim of course)
_____________________
From Studio Dora
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-22-2008 21:47
since you are moving child prims, it may be worth noting there is a bug (and fix) associated with rotating child prims, info at https://jira.secondlife.com/browse/SVC-93 (I updated LSL Portal with issue notes for those as well)
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Aloah Oh
Registered User
Join date: 2 Jan 2008
Posts: 4
|
12-23-2008 02:31
Thank you so much everyone.
To be fair Dora, I tested it for hours but didn't know about the offset which has made all the difference.
My little creatures now go and in and out like anything!!
|