Help with swing / hammock?
|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
11-17-2009 11:39
Hi, I'm dabbling with a hammock I've built. Could anyone put me in the right direction which of the rotation functions I should look into? Rotations always make my head hurt... Thanks! 
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
11-17-2009 13:48
Physical or not-physical, taht is the question...
Most go for not-physical, which is both easier, and less pleasing.
llSetPos() and llSetRot() have a 0.2 second delay (I think). Thus, jerky movement.
Easiest way, maybe: Put swing in position, record pos and rot, move it, record pos and rot, repeat. Hard code all the pos/rot combos in the script.
You ccan also search these Forums, the Wikis, and Google for swing in Second Life. This topic has been covered many times.
Goog luck.
_____________________
So many monkeys, so little Shakespeare.
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
11-17-2009 17:11
The method I choose depends on the length/speed of the rotation arc. For short, quick moves, the method Lee describes is efficient enough. However, for swings that need to be slower/smoother, I use llTargetOmega().
The concept is to store the two endpoint rots (store a third, midpoint if needed). Since llTargetOmega() is a timed move, it's easy to build a timer which alternates between forward/backward motion. For something like a see-saw, which is always at one endpoint, just start a timer, and call llTargetOmega() each timer the timer hits, with a reverse-direction variable (multiply by -1). Use the stored rots to keep things in-sync in case of lag and reset to a known starting point (such as the midpoint for swings).
|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
11-18-2009 03:43
But isn't llTargetOmega a client-side movement? Doesn't that mean that the avatar lying on the hammock will remain stationary?
|
Dekka Raymaker
thinking very hard
Join date: 4 Feb 2007
Posts: 3,898
|
11-18-2009 07:05
not when the avatar is attached to the hammock, or in the true sense the hammock becomes the attachment to the avatar.
|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
11-18-2009 10:59
Sorry, it seems I am a bit slow on the uptake here. My hammock's root prim is an invisible cylinder that stretches between the 2 points where the hammock is fastened. My rotation should be around the z axis of this cylinder.
I can't figure out how to do that with llTargetOmega. If I put the script into the root prim, the entire object will rotate around the regional z axis. If I put it in a child prim, only that child prim will rotate around it's own local z axis.
So what am I missing?
|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
11-18-2009 11:34
Sorry, no need to reply to my last question. I just needed another cup of tea. 
|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
11-18-2009 13:43
Okay, I've put a script together now, using llTargetOmega, changing direction on a timer. It works so far, but the weird thing is that when I let the hammock swing for a while, it becomes apparent that it doesn't just rotate around the z axis but gradually wanders off the x and y axes as well. I've seen that happen with other swings too. Any ideas what causes this and what I can do about it? The function reads now: llTargetOmega(llVecNorm(<0,0,dir>*llGetRot()),0.05,1); //dir alternates between 1 and -1 every 3 seconds. Thanks again! 
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
11-19-2009 08:09
Not sure why...but a workaround is to save the position whenever it is rezzed or moved. Then, every so often, move it to that position again. If you do it often enough, people won't hardly notice.
_____________________
So many monkeys, so little Shakespeare.
|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
11-19-2009 22:20
Thanks, Lee..... hmmm, tried that, it doesn't do the trick.
I think there must be something missing in my vector for llTargetOmega(), because the drifting does not occur when I line up my root prim's local z axis with one of the horizontal region axes.
Or is llTargetOmega() just borked that way?
|