Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Keeping an object above my right shoulder?

Chase Bravo
Junior Member
Join date: 18 Jun 2004
Posts: 13
06-23-2004 08:39
Hello all, last night I was trying to create a type of follow script that would keep an object above my right shoulder.
I was using the llSensoreRepeat function to track my pos then would have the object llSetPos(mypos + <2,0,2>;). This updated frequently and did a fine job (imo) of getting the object to stay with me.

Problem is, since my offset added 2m to the x coord and 2 to the z coord it did a poor job of actually keeping the object over my "right" shoulder. In reality the position of the object was always dependent on which way I was facing. So sometimes it would be in front of me, or on my left, or even behind me if I was facing a different way.

Now I know there has to be a way to keep it off my right shoulder but I can't seem to find out how. And math not being my strong point....well you can see my problem.

Would anyone here be so kind as to recommend a solution?
Any thoughts/comments are appreciated. :)
_____________________

[ c h a s e ] - nOOb scripter and learning fast.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
06-23-2004 08:52
your using a sensor to get your current pos right?

multiply your addin vector by the detected rotation.
ie
llSetPos(mypos + (<2,0,2>*llDetectedRot(me)) ).
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Chase Bravo
Junior Member
Join date: 18 Jun 2004
Posts: 13
06-23-2004 08:57
omg is it really that easy? LOL

Thanks a ton Strife!
_____________________

[ c h a s e ] - nOOb scripter and learning fast.
Chase Bravo
Junior Member
Join date: 18 Jun 2004
Posts: 13
06-23-2004 13:00
This doesn't seem to be working, did I overlook something?

vector vctOffsetPos = <2,0,2>;

sensor(integer total_number)
{
llSetPos(llDetectedPos(0) + (vctOffsetPos * llDetectedRot(0)));
}

Is it because llDetectedRot returns a rotation and I'm trying to multiply it with a vector?
_____________________

[ c h a s e ] - nOOb scripter and learning fast.
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
06-23-2004 13:51
How do you mean "not working?" Not compiling or not hovering over your left shoulder?

If it's not compiling, try:
llSetPos(llDetectedPos(0) + ( llDetectedRot(0) * vctOffsetPos));

If it compiles but is not working right, post your llSensorRepeat line (or the whole script).
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
06-24-2004 02:47
multiplying a vector by a rotation results in the vector being rotated.

http://www.badgeometry.com/wiki/Rotation
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
06-24-2004 07:45
Ah right, I can never remember which one (rotation x vector or vector x rotation) is the correct order.
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Tcoz Bach
Tyrell Victim
Join date: 10 Dec 2002
Posts: 973
06-24-2004 17:32
If you know how to do a bullet, you know how to do this.

You can rez a bullet at a particlar offset from you. It can be made to face the same way your are.

Use that logic and a sensor to keep the object floating above your shoulder (sans velocity/physics)

It definitely works. The mHUDs for Terrain worked very much like this, except they didn't float over your shoulder, they floated over your head, which is just a matter of adjusting the offset to your sensed pos/rot. As it turns out, your "jaw" is pretty consistently found at .75 the AV height.

The terrain mHUDs use essentially reversed bullet logic. Sort of like pointing a bullet at yourself, but not firing the gun.

Good luck.
_____________________
** ...you want to do WHAT with that cube? **
Chase Bravo
Junior Member
Join date: 18 Jun 2004
Posts: 13
06-25-2004 11:26
ok thanks guys, I've got the object to follow me on my right shoulder now.

Now I just gotta figure out a way to get it to face the same direction I am...::sigh::
_____________________

[ c h a s e ] - nOOb scripter and learning fast.
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
06-25-2004 12:41
That's easy,
llSetRot(llDetectedRot(0));

If your object is constructed so that a rotation of zero isn't "forward", multiply llDetectedRot(0) by whatever rotation it takes to make it face forward.
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!