|
jakal Byrne
Registered User
Join date: 14 May 2004
Posts: 8
|
05-17-2008 01:44
I am trying to make a physical object follow me above my shoulder. the problem i am running into is that its basing its vector on the world axis. so no matter which way i turn it stays in the same place unless i move. its not staying above my shoulder. how can i get it to go off my avatars local axis? here is a sample of one of my attempts. a friend tried to help me out with the math.
vector rad; rotation rot; default { state_entry() { llSensorRepeat
("",llGetOwner
(),AGENT,50.0,TWO_PI,.1); }
sensor(integer total_number) { rot = llDetectedRot(0); rad = llRot2Euler(rot); llMoveToTarget(llDetectedPos(0)+ <llSin(rad.x), -llCos(rad.x),1>,.1); llRotLookAt(rot,1,1); } }
I have tried a few different ways but this is the basic script all my attempts have been based on. all thats changed is the math i use. can anyone lend a hand?
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-17-2008 01:58
for a start try: llMoveToTarget(llDetectedPos(0)+ rad, .1);
keep it simple ......
It is not clear what direction you want it to face, but assuming it is the same as the av, then: llSetRot( llDetectedRot(0) ); (thats the simple version)
Happy scripting
_____________________
From Studio Dora
|
|
jakal Byrne
Registered User
Join date: 14 May 2004
Posts: 8
|
05-17-2008 02:08
Thank you for the reply. but my problem is not its rotation. it simply that.. well lets say my object is sitting above my right shoulder. then i turn 90 degrees to the right. suddenly my object is in front of my face instead of over my shoulder. I want it to stay over my shoulder.
Edit: sorry didnt see that you have me a suggestion on the llMoveToTarget with that line it seems to bug out. one minute its about where it should be. then i turn and it slams into the ground.
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-17-2008 03:23
this is a free follower I picked up god knows where: default { state_entry() { vector pos = llGetPos(); llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE); llSetStatus(STATUS_PHYSICS, TRUE); llSleep(0.1); llMoveToTarget(pos,0.1); key id = llGetOwner(); llSensorRepeat("",id,AGENT,20,2*PI,.4); }
sensor(integer total_number) { vector pos = llDetectedPos(0); vector offset =<-1,0,0>; pos+=offset; llMoveToTarget(pos,.3); } }
it will place the object at 'offset' relative to your av... try play with that
_____________________
From Studio Dora
|
|
jakal Byrne
Registered User
Join date: 14 May 2004
Posts: 8
|
05-17-2008 03:35
That certainly is a different way to do it. sadly it does the same thing my script does. but ill take a look at it and see if maybe this way of doing it is any better than mine.
|
|
jakal Byrne
Registered User
Join date: 14 May 2004
Posts: 8
|
05-17-2008 03:47
Oh i seem to have solved it. Instead of rad.x i needed rad.z i noticed that when in mouse look when i looked up and down the object moved left and right.
|