Change font size
It is currently Wed Nov 20, 2019 8:53 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 4 of 4   [ 34 posts ]
Go to page Previous  1, 2, 3, 4
Author Message
 Post subject: Re: Pointing your nose..
PostPosted: Wed Sep 07, 2011 12:39 pm 
OSG Elite
User avatar

Joined: Thu Dec 11, 2008 7:51 am
Posts: 391
Location: England UK
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.

_________________
"Nothing lasts forever; It's scientific"
~David Byrne (Talking Heads)


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Thu Sep 08, 2011 8:32 pm 
Furious Typer
User avatar

Joined: Mon Aug 10, 2009 11:53 pm
Posts: 258
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.
{L_CODE}:
key npc;
vector vecTo_targ;
vector nPos;
integer destX;
integer destY;
integer target_x;

default
{
    state_entry()
    {
        llListen(10,"",NULL_KEY,"");
    }
   
    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");
                llSensorRepeat("","",AGENT,92.0,PI*2,0.1);
            }
            else if (msg == "stop")
            {
                osNpcRemove(npc);
                llResetScript();                           // Stop all processes. Kill all NPCs.
            }
            else
            {
                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!

_________________
Sorry, I was just thinking upon the immortal words of Socrates who said ... "I drank what?? ... "
- Real Genius


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Mon Oct 03, 2011 7:50 am 
Furious Typer

Joined: Tue Aug 18, 2009 2:42 am
Posts: 232
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
{L_CODE}:
osNpcSetRot(npc, llEuler2Rot(<0,0,90> * DEG_TO_RAD));

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


Top
 Profile  
 
 Post subject: Re: Pointing your nose..
PostPosted: Mon Oct 17, 2011 9:54 am 
Furious Typer
User avatar

Joined: Mon Aug 10, 2009 11:53 pm
Posts: 258
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

_________________
Sorry, I was just thinking upon the immortal words of Socrates who said ... "I drank what?? ... "
- Real Genius


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 4 of 4   [ 34 posts ]
Go to page Previous  1, 2, 3, 4


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net