|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
02-22-2006 07:59
There is no problem to script movement of a child prim without moving the root. Therefore, it should be possible to script movement of the root and either have the child prim ignore or correct for that movement and stay or return to where it was before the movement of the root. I have tried recoding the child's position before the root moves using both llGetPos() as well as llGetLocalPos(), then moving the root with llSetLocalPos(), and then llSetPos() to move the child's location back to the recorded position. I have also tried moving the child prim in the opposite direction to that of the root. Neither worked. Any suggestions would be appreciated.
Mod
|
|
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
|
02-22-2006 09:44
Mod, even with the correct script, both script- and network-lag would probably ruin the effect. Might I suggest using an extra, hidden prim as the root instead.
|
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
Thanks Ben
02-22-2006 09:52
I understand the visual will be far from ideal, but in this case that is not the primary issue. I finally put together a working model using a combination of llSpeep(0's. Now, I will see if I can fine tune it a bit.
Mod
|
|
Terrin Keegan
Registered User
Join date: 15 Aug 2004
Posts: 4
|
02-22-2006 10:23
Your problem is with llSetPos(). Using it on a child prim in a linked set moves it to a position relative to the parent prim. As in the parent object's center location is considered to be <0, 0, 0> and your child's position is being set in reference to that. To do what you want you would have to record the parent's location using llGetPos() from within the parent or alternatively llGetRootPosition() from within the child prim. In this case you just need to get the child's original reference position. Use llGetLocalPos() for this. Since llSetPos() is in relation to the parent object, you just need to correct your child's local position by your parent's movement. Obviously you'll need to use link messages to move the child when the parent is moved so try the following in the child prim. I have not tested this though so it may need corrections. Hope this helps a little. vector parent_pos; vector parent_current; vector child_offset;
default { state_entry { parent_pos = llGetRootPosition(); child_offset = llGetLocalPos(); }
link_message(integer sender_num, integer num, string str, key id) { // Do whatever checks necessary for parent message here
// Get current parent and compute child offset based on old positions parent_current = llGetRootPosition(); child_offset = child_offset - (parent_current - parent_pos); llSetPos(child_offset);
//Reset position records so future movement works parent_pos = parent_current; } }
|
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
Thanks Terrin
02-22-2006 12:47
I understand the basic principle of the root being the reference point, but your code example will be helpful. I appreciate the input.
Mod
|