Pointing your nose..
Page 4 of 4

Author:  Adelle Fitzgerald [ Wed Sep 07, 2011 12:39 pm ]
Post subject:  Re: Pointing your nose..

Thanks for looking at this Haplo. I'll try and reduce the sensor and try the 'left/right sholder' thing myself. If I get the same results as yourself I'll mention it to Justin and see about raising a mantis for it (dependant on what Justin makes of it). It is possible there is some small bug as it mentions on the wiki about only using one axis for rotation.

Author:  Haplo Voss [ Thu Sep 08, 2011 8:32 pm ]
Post subject:  Re: Pointing your nose..

Ok so toying around even more with the numbers... this is as close as I can get to an even spread of right and left follow rotation.

No matter which direction you walk in circles around the NPC, it tracks and will end up facing *nearly* dead on to the direction of the avatars position.

There is still a degree, maybe two of difference, but it is very usable. On the other hand you can tell by the values used that something is definitely wrong with the rotation system here.

Here is the very stripped down version I have been testing with. Just type /10 create and it is already started. /10 stop to remove and reset.
key npc;
vector vecTo_targ;
vector nPos;
integer destX;
integer destY;
integer target_x;

    touch_start(integer num)
        llOwnerSay("\n\nNPC Block:\nType /10 (command) to control your NPC.\ncreate - spawn NPC\nstop - stop and remove the NPC");

    listen(integer channel, string name, key id, string msg)
        if (msg != "")
            if (msg == "create")
                osOwnerSaveAppearance("appearance");    // Saves object owner's appearance
                destX = (integer) llFrand (10)-5;      // Creates random X coord around center
                destY = (integer) llFrand (10)-5;      // Creates random Y coord around center
                npc = osNpcCreate ("Luke", "Endemirror", llGetPos()+<destX, destY, 0>, "appearance");
            else if (msg == "stop")
                llResetScript();                           // Stop all processes. Kill all NPCs.
                llOwnerSay("Nope");                        // Unknown command basket
    sensor (integer _det) // ----------->Avatar Movement / NPC Rotation Sensor <---------------
        integer x;
        for (x = _det - 1; x >= 0; x--) {                                // Grab incoming avatars
            if (llDetectedKey(x) != npc && llDetectedKey(x) != ""){      // Filter for target
                target_x = x;
                vecTo_targ = llList2Vector(llDetectedPos(target_x),0);   // Grab vector to target
                nPos = osNpcGetPos(npc);       
        osNpcSetRot(npc, llRotBetween(<PI*7,PI*-1,0>,llVecNorm(vecTo_targ - osNpcGetPos(npc))));

P.S. I went ahead and posted a minor Mantis on this, included all of the important observations I've found on it, and hopefully something will be found. justin has been really great about the NPCs but I so understand if they are bottom of the list. I'm just glad we have them at all finally. :mrgreen:

If you find anything else out for us please post. I'm really interested now that I don't understand all the math behind it..... I want to understand it even more! hah!

Author:  Eryn Galen [ Mon Oct 03, 2011 7:50 am ]
Post subject:  Re: Pointing your nose..

Thanks to Marcus I have a nice NPC receptionist for the OSGazet headquarters now :)
I had the rotation problem when I first placed her though, but I was able to crack it using a little tweak I use in my normal sit scripts. The NPC is sitting stationary though, so it might be something else...
After the osNpcCreate I just added one line
osNpcSetRot(npc, llEuler2Rot(<0,0,90> * DEG_TO_RAD));

and presto, she turned 90 degrees to the left ;)

Author:  Haplo Voss [ Mon Oct 17, 2011 9:54 am ]
Post subject:  Re: Pointing your nose..

I should have posted this earlier!

As far as a standing still NPC, simply rotating to track someone's position - the vector / rotations we've been discussing are still the only method I know of to do so.

HOWEVER... The devs have been extremely nice in paying attention to requests and osNpcMoveTo has been revamped to always point towards the target destination. End result being there is no longer a need for any calculation of rotation once the target is set.

So all this means is, if your NPC is moving to walk a path or follow a target, then it will automatically face said target.

Take care,
- Hap

Page 4 of 4 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group