Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Holding a stick upright

Boreal Latte
Registered User
Join date: 15 Nov 2007
Posts: 104
04-14-2008 00:21
Hi. If I attach a prim to my hand, it moves around with my hand - pointing in direction depending on the animation played. Is there a way to combine the get and set rotations so that the stick keeps upright. Uprighting it every second or so is good enough. It seems the llGetRot returns the rotation of the avatar, while llSetRot is relative to the attachment point. I have not had any luck with the GetLocal or SetLocal either.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
04-14-2008 01:15
Use one of the built in animations to make the hand hold the stick.

http://wiki.secondlife.com/wiki/Internal_Animations

[edit]

you'll find an example of how to use animations (including a complete list of the built in anims) here:

http://www.lslwiki.net/lslwiki/wakka.php?wakka=ExampleAnimationScript
Boreal Latte
Registered User
Join date: 15 Nov 2007
Posts: 104
Can it be done by scripting
04-14-2008 02:18
Thanks a lot Haruki. That is a gem off animations, and all preloaded for fast execution.

I was wondering if it can be done using a script - can I rotate the stick in my hand in a predictable manner - or perhaps put a compas arrow that always point north on top of my stick?
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
04-14-2008 02:36
Since animations are handled client side, attachments have NO information whatsoever on their relative position and rotation to the avatar. Therefore what you wish to accomplish is not possible through scripts. All you can get is the avatars position and rotation.
Cortex Draper
Registered User
Join date: 23 Aug 2005
Posts: 406
04-14-2008 06:38
I would think the best way would be to use a script in the object to activate the animation when worn.
Have a high priority animation keeping your hand up and allow you to move in all other body locations.

Use a 2 frame animation where the only difference between the 1st and second frame are in the arm and hand joints.
Second life uses a difference from the initial frame to tell it that your animation is contolling that location.
If the values are the same in all other locations in both frames, then SL knows the animation doesnt controll those locations so allows you to move

Example: I could make a burning torch that my avatar holds up, but I could still walk about while holding it, and my legs would move while I walked since the torch animation only controlls the arm.
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
04-14-2008 06:59
From: Squirrel Wood
Since animations are handled client side, attachments have NO information whatsoever on their relative position and rotation to the avatar. Therefore what you wish to accomplish is not possible through scripts. All you can get is the avatars position and rotation.


Right -- scripts can't know how the animation moves the avatar or its body parts, so they can't know their actual location or orientation, either relative or globally.

Other than the suggestions mentioned above, the only workaround I can think of is to try to coordinate the script with the animation, but timing would be "open loop" and thus would it only work well with low lag (not to mention being tedious to code).
Cortex Draper
Registered User
Join date: 23 Aug 2005
Posts: 406
Particle method
04-14-2008 07:00
A completely different way not using animations:

If your stick was a particle emited by an object in your hand you could easily make it always remain upright. A particle is basically a 2d picture that could be centred on the object in the hand. Its easy to set them to be always upright.

Unfortionately it wont look as good as using a 3d object held there by an animation.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-14-2008 09:32
For the compass bit, once you DO have an animation that'll keep the attachment position aligned in a known or predicable fashion compared to the avatar's hips, you could align the attachment relative to the attach point (hand) from the script, and then figure out how to rotate the compass bit relative to the stick as calculated from the avatar's rotation. For example, if the root prim's z-axis is pointed up, start the compass prim pointing North when the avatar is facing East (zero rotation), then rotate it about the object's z-axis by the same amount (but in the opposite direction) the avatar is rotated from the global x-axis.
Boreal Latte
Registered User
Join date: 15 Nov 2007
Posts: 104
04-14-2008 11:25
Thanks folks. I am now fully convinced that there was no "easy way" I had overlooked. I even tried letting the compass needle be a physical object that would follow a thing I held in my hand. But alas, the animations are truly client side, and hence the needle faithfully follows a different spot than where the hand is.

I will see if I can make some other workarounds. I am not sure I am ready for the animation part as it might be a bit of an overkill for my plan. I never tried to make an animation, and right now is not the best time for me to sink that amount of building time into this :-)
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-14-2008 14:08
From: Boreal Latte
I am not sure I am ready for the animation part as it might be a bit of an overkill for my plan. I never tried to make an animation, and right now is not the best time for me to sink that amount of building time into this :-)

You MIGHT be able to get away with using the "hold_r_handgun" animation. It's probably worth a try if you don't want to dive into animation yourself.
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
04-14-2008 14:41
Perhaps you could set it 'flexible' and set the gravity parameter on it negative ^^
_____________________