Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Having an Object Rotate With Another

Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
01-01-2010 14:07
I want to have two objects.

Object A

Object B

I want object A to move around freely, but have object B keep exactly 80m away and have it rotate with object A.

Like they're linked, but there too far apart to be linked.

Does anyone know if it's possible if so how?

I would think some kind of fast updating timer with trig?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-01-2010 14:30
does object B follow object A or is it also expected to rotate in an arc around object A so that it's in the same relative position?

how does object A move? via vehicle controls? if so you could just send the same control messages to both objects.
_____________________
|
| . "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...
| -
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
01-01-2010 14:45
From: Nyx Alsop
I want to have two objects.

Object A

Object B

I want object A to move around freely, but have object B keep exactly 80m away and have it rotate with object A.

Like they're linked, but there too far apart to be linked.

Does anyone know if it's possible if so how?

I would think some kind of fast updating timer with trig?
Is A physical? is B physical? are both physical? is one a vehicle? are both? How is A moving, on a straight line? fast or slow? Are A and B single prims or linksets? Is one a prim and the other a linkset?
_____________________
From Studio Dora
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
01-01-2010 17:05
Vehicle,

It's ment to orbit it like the moon round the earth, but stay in the same oribited position as the vehicles facing.
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
01-01-2010 17:06
I want to double sensor range in the vehicle.
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
01-02-2010 01:30
That's relatively easy.

Make your vehicle rez its follower and say its key on a "hidden" channel.

I assume that the follower is NOT physical and that the "hidden" channel was given as rez parameter. Here is a simple follower script:

(Quote me!)
CODE

// Position of the follower relatively to the vehicle
// (You can also have it transmitted through chat.)
// And it can be as far as you need, of course...
vector Offset = <-5, 0, 1>;

key VehicleKey;
integer Handle;

default
{
on_rez(integer hidden_channel)
{
llSetTimerEvent(0.0);
if (hidden_channel)
{
// I was rezzed by an object. Let's listen to it.
Handle = llListen(hidden_channel, "", NULL_KEY, "");
}
}

listen(integer channel, string name, key id, string msg)
{
llListenRemove(Handle); // Not needed any more.
VehicleKey = id;
llSetTimerEvent(0.25); // Can't go any faster.
}

timer()
{
list tempo = llGetObjectDetails(VehicleKey, [OBJECT_POS, OBJECT_ROT]);
vector vehicle_pos = llList2Vector(tempo, 0);
if (vehicle_pos != ZERO_VECTOR)
{
rotation vehicle_rot = llList2Rot(tempo, 1);
llSetPrimitiveParams([
PRIM_POSITION, vehicle_pos + Offset * vehicle_rot,
PRIM_ROTATION, vehicle_rot
]);
}
else
{
// Vehicle was lost...
}
}
}


The vehicle will be lost when derezzed (of course) but also when crossing a border. Either if the vehicle itself crosses a border or if the follower position is in a neighboring region.

One way around this is to try to follow the driver/avatar if the vehicle can't be found. It requires some adaptation because the av isn't at the same position than the root (usually) and if the sit target is rotated relatively to the root, it adds some more complexity but it's doable.

Any way, this is a simple script. You'll improve it.
_____________________
It's hard to tell gender from names around here but if you care, Kaluura = he. And I exist elsewhere than in SL but who cares? ;)
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
01-02-2010 05:48
Yeah but isn't that just going to rotate the prim like the vehicle is?

Rarther than acting like an orbit would, and have both objects X axes always facing foward?
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
01-02-2010 06:29
Yes it will... and no it won't. :P

Simple RL experiment in 3D: Extend your arms before you, your left hand flat over your right hand. Rotate your right hand in 3D and keep your left hand in contact. The fingers of both hands always point in the same direction.

That's what my little script does: To keep the left hand (the follower) in contact (at a constant offset with the same rotation) with the right hand (the vehicle).

You can add some (non-breakable, plz!) object in between your 2 hands and observe that it works whatever the offset is.

So it won't... but it will. ;)

The trick is in the offset to which the rotation of the vehicle is also applied. This makes a big difference.
_____________________
It's hard to tell gender from names around here but if you care, Kaluura = he. And I exist elsewhere than in SL but who cares? ;)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-02-2010 08:41
being as it's too far to be linked, a straight move position may be too great to handle (more than 10m) so if it's non physical you may want to use something like warpPos, or a similar stepped movement, and you'll also want to check that that new position isn't going to be offworld at the very least, and preferably that it isn't over no script land (although you can add do nothing controls to get around that)... no object entry parcels may prove to be a problem. for a physical follower you can possibly get away with using move to target, since it has a range of ~58m for the move.
_____________________
|
| . "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...
| -
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
01-02-2010 09:15
The going off world is going to be the main problem, but I guess I can just do a check and move it closer.