|
Aries Redgrave
Registered User
Join date: 28 Jun 2007
Posts: 5
|
07-19-2007 12:53
Not sure if that title explains it right. Basically I have object A which rezzes object B infront of it..
I would like it that when I rotate object A that object B either automatically follows, or that when I click a button, object B adjusts itself to being infront of object A.
Hopefully that makes sense. xD
|
|
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
|
07-19-2007 12:57
Sound like a modify follow script should do the trick for you. Have the senor in the following script detect the position of the leader. You can also have the leader send chat commands to the following object also.
|
|
Aries Redgrave
Registered User
Join date: 28 Jun 2007
Posts: 5
|
07-20-2007 12:26
Alright so I tried adding a modified follower script to it, and well it's not working as intended.
In the original follower script, the prim would move as I turned which was great. But when I tried to impliment this to have it follow another object it just won't work. It just stays there floating and not moving when I moved the object. =/
It all basically comes down to this bit of code. "vSitTarget" is my adjustments to where I want it to be positioned.
adjsit = vSitTarget; basicsit = llDetectedPos(0); finalsit = basicsit + vSitTarget;
llMoveToTarget(finalsit*llDetectedRot(0),.3);
In the original follower script it had this:
floatcountplus(); vector pos = llDetectedPos(0); llMoveToTarget(pos+offset*llDetectedRot(0),.3);
floatcountplus(); basically just made the prim bob up and down.
Basically what I'm trying to make is a BDSM furniture that works like Sexgen beds. I got just about everything down except this last bit.
Any ideas would be greatly appriciated.
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
07-20-2007 13:57
lets see the sensor() call?
|
|
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
|
07-21-2007 00:30
I can't give an exact answer because I always have to look it up myself too, but I can walk you through the thought process to make it easier to understand what you need to do.
If I'm reading this right this is just another orbit problem. There are two things you need to do: calculate a new satellite rotation, and a new satellite position.
Satellite rotation is usually the same as the base rotation. That's the easy part. If the satellite had a pre-existing rotation then you'd need to add the angles together by multiplying them (yes, that's not a typo, sorry).
Satellite position is based by adding an <x,y,z> offset to the center of rotation (the base prim). The offset is set by multiplying the magnitude of the offset (the distance from the base to the satellite) by the rotation applied. The quat that expresses the rotation is actually composed of sine/cosine/theta/I forget what else - and these trigonometric values are actually nothing but ratios of x & y for each given angle - If the sine for a given angle is 0.5, then that means a 2 meter pole at that angle would only advance 1 meter along ... the y axis, I think. Multiplying the offset by the rotation does the same thing, basically. Anyways, Just be aware you need to multiply the magnitude by the rotation. Also, when you do that multiplication, you need to do it in a certain order, its not transitive. offset*rot is not the same as rot*offset.
Also, you need to convert to the proper units of measures. Compass rotations (Euler) are expressed as 0-360 degrees and are stored in vectors. Rotations are express in quats. You can't convert directly between the two because the conversion functions expect/return Euler measurements in radians. There's a pair of constants you can use for this.
You can probably get lucky by searching the forums for "orbit rotation" or searching google for "lsl orbit rotation", its only a few lines of code.
Good luck!
|
|
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
|
07-21-2007 10:04
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
07-21-2007 12:38
1. Rez a prim, place this script in it, name it "Object B" 2. Rez another prim, name it "Object A" 3. move/rotate Object A, and Object B will follow it. // Object B script - follows object A // Written by Boss Spectre
vector offset = ZERO_VECTOR; rotation baserot = ZERO_ROTATION;
default { state_entry() { llSensorRepeat("Object A", "", ACTIVE | PASSIVE, 20.0, PI, 1.0); }
sensor(integer num_detected) { rotation rot = llDetectedRot(0); if (offset == ZERO_VECTOR) // store offset once { baserot = llGetRot() / rot; offset = (llGetPos() - llDetectedPos(0)) / rot;; } llSetPrimitiveParams([ PRIM_ROTATION, llDetectedRot(0) * baserot, PRIM_POSITION, llDetectedPos(0) + (offset * rot) ]); } no_sensor() { offset = ZERO_VECTOR; } }
|