Problem rotating an avatar using RLV - SLUniverse Forums
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » Problem rotating an avatar using RLV


Scripting Discuss scripting and programming for SL and other platforms

 
Reply
 
LinkBack Thread Tools Display Modes
Old 01-01-2018, 06:58 PM   #1 (permalink)
*blink*
 
Soen Eber's Avatar
Vatican mole
 
Join Date: Oct 2009
Location: Minneapolis, Minnesota, USA
Posts: 7,058
My Mood:

Awards: 1
SLU Creepy Avatar Competition 2014 Participant 
Problem rotating an avatar using RLV

I'm trying to update that fancy key that sticks out of my back so when someone winds it, I stand up (if sitting), turn around to face them, and bow. The immediate problem is in turning around - I have the syntax right, but nothing is happening.

Code:
        llWhisper(0,llGetDisplayName(_id_Agent)+" has wound "+llGetDisplayName(llGetOwner()));
        llOwnerSay("@unsit=force");

        llOwnerSay("starting setrot");
        llOwnerSay("id_Agent="+llKey2Name(_id_Agent));
        list l = llGetObjectDetails(_id_Agent, [OBJECT_POS]);
        llOwnerSay("l="+llList2CSV(l));
        vector agent_pos = llList2Vector(l,0);
        llOwnerSay("agent_pos = "+(string)agent_pos);
        vector diff=llGetPos() - agent_pos;
        llOwnerSay("diff = "+(string)diff);
        float pointTo=llAtan2(diff.x, diff.y);
        llOwnerSay("pointTo="+(string)pointTo);

        string rlvcmd = "@setrot:" + (string)pointTo + "=force";
        llWhisper(0,rlvcmd);
        llOwnerSay(rlvcmd);
And here's my debug messages:

Code:
[16:51] Soen's New Doll Key 1.8 whispers: Heather Drum has wound Soen Eber
[16:51] Soen's New Doll Key 1.8: starting setrot
[16:51] Soen's New Doll Key 1.8: id_Agent=Heather Drum
[16:51] Soen's New Doll Key 1.8: l=<220.210098, 14.253438, 551.332886>
[16:51] Soen's New Doll Key 1.8: agent_pos = <220.21010, 14.25344, 551.33290>
[16:51] Soen's New Doll Key 1.8: diff = <2.49471, -0.79156, 0.11041>
[16:51] Soen's New Doll Key 1.8: pointTo=1.878045
[16:51] Soen's New Doll Key 1.8 whispers: @setrot:1.878045=force
The debug log looks nice & normal, but I'm not turning around. I'm standing, so rlv is working...and yes, I know it's potentially off by 6 to 10 degrees, I can live with that.

Thanks for any help you can offer.
__________________
Hey troll, don't you have a rapture to pray for or some poor people to run over or some beatitudes to ignore or newspapers to burn or something?

You can wish-list items and return to SLU to purchase through the affiliate link.
Note: Some people refuse to buy from Amazon due to predatory tactics against publishers as noted here and here by Jacqueline Trudeau.
Soen Eber is online now   Reply With Quote
Old 01-02-2018, 08:08 PM   #2 (permalink)
Senior Member
 
Sei Lisa's Avatar
My first name is Sei
 
Join Date: Aug 2013
Posts: 233
My Mood:
Quote:
Originally Posted by Soen Eber View Post
Code:
        vector diff=llGetPos() - agent_pos;
Isn't this the other way around?

PHP Code:
        vector diff=agent_pos llGetPos(); 
If you're looking almost opposite to them, you won't probably see any effect because of the roughness of avatar rotation.

Edit: Hmm... another factor is that the unsit needs to arrive to the sim and become effective before you can turn. Try inserting a sleep. Perhaps also use llUnSit(llGetOwner()) instead of @unsit=force, so that the sim doesn't have to wait for the command to arrive.
__________________
Tools for scripters that I'm the maintainer of:
LSL-PyOptimizer (NEW: Try it online!) | LSL Calculator | Unofficial LSL Reference Wiki | LSL Keywords Database

Last edited by Sei Lisa; 01-02-2018 at 08:15 PM.
Sei Lisa is offline   Reply With Quote
1 User Said Thanks:
Old 01-17-2018, 04:18 AM   #3 (permalink)
Thread Killer
 
Adeon Writer's Avatar
 
Join Date: Apr 2010
Posts: 10,537
SL Join Date: May 2007

Awards: 2
SLU Creepy Avatar Competition 2014 Participant 
Yep, that entire block consists of 0 delay function calls - so the whole thing finishes execution instantly - while you are still sitting.

Instead of a llSleep could throw in a while() after the @unsit that does nothing until llGetAgentInto no longer contains AGENT_SITTING. That will pause the script only the exact amount needed to continue safely.
Code:
        llWhisper(0,llGetDisplayName(_id_Agent)+" has wound "+llGetDisplayName(llGetOwner()));
        llOwnerSay("@unsit=force");
        while(llGetAgentInfo(llGetOwner()) & AGENT_SITTING) { }
        llOwnerSay("starting setrot");
        llOwnerSay("id_Agent="+llKey2Name(_id_Agent));
        list l = llGetObjectDetails(_id_Agent, [OBJECT_POS]);
        llOwnerSay("l="+llList2CSV(l));
        vector agent_pos = llList2Vector(l,0);
        llOwnerSay("agent_pos = "+(string)agent_pos);
        vector diff=llGetPos() - agent_pos;
        llOwnerSay("diff = "+(string)diff);
        float pointTo=llAtan2(diff.x, diff.y);
        llOwnerSay("pointTo="+(string)pointTo);

        string rlvcmd = "@setrot:" + (string)pointTo + "=force";
        llWhisper(0,rlvcmd);
        llOwnerSay(rlvcmd);
Adeon Writer is offline   Reply With Quote
1 User Said Thanks:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On




SEO by vBSEO