Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Rotating linked objects.

Dragon Grimm
Not a junior member.
Join date: 2 Apr 2003
Posts: 8
05-24-2003 23:33
This script makes a linked object rotate continuously, the way it works is that when you apply this script to a child object (the object you want to rotate) it will check the parent's local rotation wich seems to be the only way to do this.

CODE

default
{
state_entry()
{
//multiply desired rotation (<x,y,z>) with local rotation of parent, rate is PI, gain is 1.
llTargetOmega(<0,0,0> * llGetLocalRot(),PI,1.0);
}

}


The reason the script multiplies the rotation with the local rotation of the parent is that all linked objects use the local rotation of it's parent instead of the world rotation axis so that it stays the same when the parent object is rotated at a different angle. This may seem a bit simple because all it is is the modified rotate function but I felt I needed to address this change because many people don't know this little piece of extra code needed.

Usage:
First link the object you want to rotate with the main object.

Make sure you select the rotator object first, then the main object so that the main object becomes the parent.

After this is done select the rotating object using select individual, then simply put the script in that object and you're all set.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
Original Thread:
01-21-2005 13:28
/15/8b/2698/1.html

I need an added idea

Thanks much. I was looking for this kind of information.

But this script seems to be usable when the moving object is just one, no linked.
I make a linked object and make it move by the gross, and when I want it to link
to another object that must be a root one, what should I do?
Anyone, let me know, plz.
Punklord Drago
Registered User
Join date: 8 Sep 2004
Posts: 22
01-25-2005 06:01
take out the * llGetLocalRot()
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
01-28-2005 07:14
Imagine a helicopter.
Like this ;)

X <--- a propeller
I <--- a shaft
O <--- a body

You can make a propeller with a shaft spin by the only TargetOmega script.
But you'll find that it will not work well when it comes to link it to the body.
The script will make even the body spin.
Useing the avobe script, you'll find just the shaft spin,
the body and the poropeller remain stationary, I don't know why.
Barbarra Blair
Short Person
Join date: 18 Apr 2004
Posts: 588
01-28-2005 10:03
You would need to rotate the blades and shaft separately (but together). However, you probably don't need to rotate the shaft, really.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
01-31-2005 07:14
Barrbara, you're right in deed.
But the point is that I need to rotate a couple of objects linked each other
together, and keeping to rotate those objects, linking them to the other stable one.

Imagine, there are three blades and a body, no shaft.
I cross three blades and link them one another to build a propeller. And I can rotate
them completely together. Then, can I link them to the body
Simple rotating script doesn't work at all. What about Dragon's (above) one
You'll see just the (former) parent blade spin (worse sitll by different axis) and
other blades remain stationary in spite of getting along with until a while ago.

Someone might say,"Build a propeller of one prim like a saucer tube, and paint
blades by texture". Ya, you're right for my example, but what I want to do is....
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
01-31-2005 21:20
If all you want to do is to rotate a blade around it's end instead of it's middle, that's easy.

Take a cube and use cut to remove 50% of it: begin = 0.375 end = 0.875

Now make the blade out of that with the Y dimension being the length of the blade X 2 (you cut away 1/2 of Y in the 1st step).

By doing this, you will see that the centerpoint of the blade prim is now at one end (the old center) of the remaining prim. By cutting the prim another 25% you can put the centerpoint in a corner instead of the middle of one end... Makes for some interesting possibilities there as well.

The only downside is the max blade length is reduced from 10 to 5 meters... If you need longer blades thatn that you'll need to figure out some other method. The draw blades on a disk method has the same limitations though (1/2 of 10 meters per blade) so there's no loss using my method.

This works for making single prim doors as well... just edit the rotation script to change the axis of rotation to match whatever final prim shape you end up using...
Gryphon Stonebender
Registered User
Join date: 25 Jan 2005
Posts: 24
02-01-2005 19:57
OK this works well... What is "linking objects"? I'm sure I do it, but I do not know it bt that name?

Also is there a way to control the speed of the spin? Does changing the llGetLocalRot(),PI,1.0); do somthing? what is the max/min?

thanks,
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
02-02-2005 19:35
Linking objects is what you do when you hit "<ctrl>+L" after selecting serveral prims you want to make into a joined group. The last prim selected is known as the 'base'/'root'/'parent' prim.

EG: make 3 spheres of different sizes, stack them verticaly with the largest on the bottom and smallest on the top. Select all 3 and link them to get a very basic snowman shaped object.

In the example above, llGetLocalRot is defining the axis of rotation (in relation to the base prim), the PI field represents how far to spin each second in radians (larger number is faster, smaller number is slower). The last field gets tricky and has to do with how 'physical' objects interact with each other OR 'how much force does the spin have?' I'm guessing it can be thought of as torque. EG: drop a ball on a spinning fan and it gets bounced off in some direction. The more torque, the harder the ball got hit and the less the fan was slowed down by the impact.

This link explains in more detail how llTargetOmega works to rotate a prim: http://secondlife.com/badgeo/wakka.php?wakka=llTargetOmega

Racer P.
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
03-18-2005 23:08
Since you are multiplying the zero vector by the root prim's rotation, your net rotation vector will be zero as well, which causes llTargetOmega not to rotate anything. I would recommend using a non-zero literal factor, such as <0, 0, 1> or <0, 0, 0.1>. (Tested with 1.5.14).
Michael Psaltery
Registered User
Join date: 6 Jun 2004
Posts: 57
04-01-2005 15:24
The effect I have observed appears to involve the order in which you link the prims. In this case, if the propeller and shaft are children and the body is the parent of the object, then setting the target omega should work (at least it seems to in my scripts... until you attach an avatar to it, as with vehicles)

One probably more resource-friendly solution to the problem might be to use a texture with transparency and apply to a disc, using llSetTextureRotation() to animate it. This is used for wheels in the various vehicle examples I have seen.

From: Seagel Neville
Imagine a helicopter.
Like this ;)

X <--- a propeller
I <--- a shaft
O <--- a body

You can make a propeller with a shaft spin by the only TargetOmega script.
But you'll find that it will not work well when it comes to link it to the body.
The script will make even the body spin.
Useing the avobe script, you'll find just the shaft spin,
the body and the poropeller remain stationary, I don't know why.
Arcane Muromachi
Registered User
Join date: 21 Mar 2005
Posts: 1
Probs
04-06-2005 16:27
Here is the problem I am having... I have multiple objects, around 6, that I have spinning in different directions at diff speeds. When I link them together, take the linked object and then drop (rez) the object anew... The objects refuse to move... I tried the script u listed and added them to each object in the link one at a time, but still it doesn't move... I tried making them all phantoms, didn't matter... They were moving before I took it and dropped it... The 6 objects are touching eachother, and it almost looks like their vibrating a little, as if they are not moving because they are colliding with one another, not sure as to why... Physics is off, so that isn't it... How do I get the parent and children prims to perform their different moves, or is this even possible?

Thanks,

Arcane
Komuso Tokugawa
Registered User
Join date: 3 Mar 2005
Posts: 93
04-23-2005 07:13
Has anyone got the script at the thread top to work?

I keep getting really weird results.


It seems to work when I build it (sometimes???) and then when I inventory it and re-rez it it sits there doing nothing.

Script resets make it jerk into motion, then it stops.

Occaisionally I'll leave it for awhile and then find the whole linked object rotating.

Any tips?

thank you,
kt
Komuso Tokugawa
Registered User
Join date: 3 Mar 2005
Posts: 93
04-23-2005 23:08
Has anyone got this to work?

I keep getting weird results.

It seems to work whne I build it, but when I take it and rerez it just sits there.
Sctipt restart makes it jerk, and then stop.
Sometimes after a while it starts rotating, but the whole linked object does it.

Any clues?

many thanks,
kt
Damian Zander
Wicked, Inc.
Join date: 21 May 2004
Posts: 19
04-26-2005 14:29
That's happened to me as well. Good to know I'm not crazy. Any solutions?
Zalandria Zaius
Registered User
Join date: 17 Jan 2004
Posts: 277
rezzing
04-27-2005 11:14
There's always been a problem with llTargetOmega on child prims when you rez it... I don't think I've ever had it work after rezzing without resetting everything. Go with animated textures if you can, they don't seem to have the same issues..
Komuso Tokugawa
Registered User
Join date: 3 Mar 2005
Posts: 93
04-27-2005 19:45
Textures? Strange solution to rotate child groups I would have thought.

I don't understand why something as basic as the ability to arbitrarily rotate groups and independant subgroups of objects does not work in sl. That's basic engine functionality.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
04-28-2005 03:49
From: Racer Plisskin

The only downside is the max blade length is reduced from 10 to 5 meters... If you need longer blades thatn that you'll need to figure out some other method. The draw blades on a disk method has the same limitations though (1/2 of 10 meters per blade) so there's no loss using my method.


It occured to me that for something like a rotor blade (although not a door) that a cut from say 0.025 to 0.975 (which I think works, but I can't get in world) would give you a prim that is kite shaped, with the centre at one end, and a length of about 7m (5root2).

It won't work for doors, probably, but might look ok for a rotor.
Spartan Mistral
Registered User
Join date: 2 May 2006
Posts: 2
05-02-2006 18:07
From: Arcane Muromachi
Here is the problem I am having... I have multiple objects, around 6, that I have spinning in different directions at diff speeds. When I link them together, take the linked object and then drop (rez) the object anew... The objects refuse to move... I tried the script u listed and added them to each object in the link one at a time, but still it doesn't move... I tried making them all phantoms, didn't matter... They were moving before I took it and dropped it... The 6 objects are touching eachother, and it almost looks like their vibrating a little, as if they are not moving because they are colliding with one another, not sure as to why... Physics is off, so that isn't it... How do I get the parent and children prims to perform their different moves, or is this even possible?

Thanks,

Arcane


I'd suggest making the objects Phantom. Turning physics on simply means it's affected by gravity, is capable of tipping over, etc.
Derek Freelunch
Registered User
Join date: 6 Jun 2006
Posts: 1
07-06-2006 09:57
Problem? The given code has <0,0,0> for a rotational axis. Just a thought.
Boris Oconner
Registered User
Join date: 21 Jul 2006
Posts: 16
10-07-2006 15:51
You are right you know.
Erzsabet Bergbahn
Registered User
Join date: 18 Nov 2006
Posts: 2
07-09-2007 16:15
From: Zalandria Zaius
There's always been a problem with llTargetOmega on child prims when you rez it... I don't think I've ever had it work after rezzing without resetting everything. Go with animated textures if you can, they don't seem to have the same issues..


The trick is to have the script reset itself when you rez it:

on_rez(integer start_param)
{
llResetScript();
}
Blonde1 Tone
Registered User
Join date: 3 Mar 2007
Posts: 1
Spinning My Head Instead!?!?!
07-29-2008 18:54
I seem to be having the exact same problems!

CUBE1 (has spin script)

CUBE2 (no script, but linked to CUBE 1 - Spins nicely with CUBE1)

CUBE3 - No Scripts, Not Linked.

So far so good, two cubes spinning. However, I do NOT want CUBE3 to spin.

So my thinking wuld be, select CUBE1/CUBE2 and link them to CUBE3. And I should have 3 prims linked, but only CUBE1 and CUBE2 Spinning?

Wrong! Only CUBE1 remains spinning! CUBE2 is now stationary! (Along with CUBE3 of course)

Obviously if I select CUBE3 First and then link to CUBE1/CUBE2, then all 3 spin.

But as I said, I do NOT want CUBE3 to spin.

So how the heck do I get this to work so CUBE1/CUBE2 spin together and CUBE3 ramains stationary, but all 3 prims linked?

I had thought about a code for CUBE2 which checked the rotation of CUBE1, but in the end it would be messy and probably not the correct way to go about this.

Does anyone have an answer? Coz it's bustin my head, which is now spinning!

Thx...