Easy way to set a Sit Target
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-02-2007 09:10
Some complaints yesterday in another thread that the only way to set llSitTarget was through trial & error. Came up with this and it works great. //Put script in prim & sit on it //Go into edit and check the "Edit linked parts" box //Move the prim to the postion you want //Touch the prim to set the llSitTarget & remove the script //Sit Target is a property of the prim and doesn't need //the script, once set //Put the prim where you want and when you sit on it //you will be in the right position
vector pos; rotation rot = ZERO_ROTATION;
default { state_entry() { pos = llGetPos(); llSitTarget(<0,0,0.01>,rot); } touch_start(integer total_number) { vector new_pos = pos - llGetPos(); llSitTarget(new_pos, rot); llRemoveInventory(llGetScriptName()); } }
Hope it helps!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-02-2007 09:51
From: Jesse Barnett Some complaints yesterday in another thread that the only way to set llSitTarget was through trial & error. Came up with this and it works great. //Put script in prim & sit on it //Go into edit and check the "Edit linked parts" box //Move the prim to the postion you want //Touch the prim to set the llSitTarget & remove the script //Sit Target is a property of the prim and doesn't need //the script, once set //Put the prim where you want and when you sit on it //you will be in the right position
vector pos; rotation rot = ZERO_ROTATION;
default { state_entry() { pos = llGetPos(); llSitTarget(<0,0,0.01>,rot); } touch_start(integer total_number) { vector new_pos = pos - llGetPos(); llSitTarget(new_pos, rot); llRemoveInventory(llGetScriptName()); } }
Hope it helps! I'm cofused, would pos - llGetPos() = ZERO_VECTOR thus removing the sittarget in the touch event? or are you saying set it, sit on it, move it to where you want the av to be, then touch? I know my big complaint with sitarget has always been rotation... whcich I solved a similar way... place the object at ZERO_ROTATION, sit the av, rotate untill correct, then have a touch report the rotation to use in the sit target... maybe you could include both? (read: I'm too lazy to do it) =)
_____________________
| | . "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... | - 
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-02-2007 10:10
From: Void Singer I'm cofused, would pos - llGetPos() = ZERO_VECTOR thus removing the sittarget in the touch event?
or are you saying set it, sit on it, move it to where you want the av to be, then touch?
I know my big complaint with sitarget has always been rotation... whcich I solved a similar way... place the object at ZERO_ROTATION, sit the av, rotate untill correct, then have a touch report the rotation to use in the sit target... maybe you could include both? (read: I'm too lazy to do it) =) 1)Script starts and pos is declared. 2)Sit on prim, right click/Edit prim, select "Edit linked parts". 3)Now you can move the prim to where you want and your avatar will not move. 4)When you are happy with how it looks then Touch the prim. When you touch it, it will subtract the stored pos from where the prim is currently at and redefines llSitTarget to this offset. Yep I was just playing with rotation and it sucks. Fine for most shapes including spheres. Just make sure the sphere's rotation is zeroed 1st. But it is still a problem is you want a torus rotated at 90 degrees on Y axis for example. I'll hopefully figure out something on it. Other then rotations, it works really nice. Try it on a cube in world. Really fast and easy.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
12-02-2007 11:00
Try this freebie: [img]http://slexchange.com/modules.php?name=Marketplace&file=item&ItemID=318690[img] http://slexchange.com/modules.php?name=Marketplace&file=item&ItemID=318690Handles rotations & everything. A note about either of these methods: you can't shift-drag to duplicate such a chair. Well, if you do, it loses the sit target. In order to survive shift-drag to copy, you need to put the coordinates in the script and set sit target on rez (or perhaps default state entry -- I'm not sure what the state of a script is after shift-drag to copy).
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-02-2007 11:14
WOOHOO!!!!!!!!!!!!!!!!!! Got it. Now it makes no difference what the rotation is and works with all shapes: vector pos; rotation rot;
default { state_entry() { pos = llGetPos(); rot = ZERO_ROTATION / llGetRot(); llSitTarget(<0,0,0.01>,rot); } touch_start(integer total_number) { vector new_pos = pos - llGetPos(); new_pos = new_pos * rot; llSitTarget(new_pos, rot); llRemoveInventory(llGetScriptName()); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-02-2007 11:39
heh I didn't even think about the edit linked parts bit... that's awesome... and nice work on the rotation.... I'll have to test it on some objects that don't have normal base rotations (like hollow half cut cubes)... something about that / llGetRot bothers me though... not sure it's gonna do as expected in all circumstances.... but I already love this, and so will my friend that builds furniture...
it'll certainly make offset poses much easier to do (using poses that move the av offcenter so that when they get up, they are standing in front, not on top or flying 50 feet due to physics)
_____________________
| | . "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... | - 
|
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
12-02-2007 11:47
/54/a8/202339/1.htmlEasy Sit Target Positioner Good to put in furniture, and uses the llSetLinkPrimitiveParams trick on the avatar to recalculate and change sit positions on the fly.
|