Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005677opensim[REGION] Script Functionspublic2011-09-06 08:292011-09-21 14:24
ReporterQuin3y 
Assigned To 
PrioritynormalSeveritymajorReproducibilitysometimes
StatusnewResolutionopen 
PlatformOSOS Version
Product Versionmaster (dev code) 
Target VersionFixed in Version 
Summary0005677: NPC movement functions are problematic
DescriptionThe avatar tends to move further than the distance set in the code, and both osNpcMoveto() and osNpcMoveToTarget() have this problem. Here is my testing situation. I tested it on my own region Quincyland. Jane Doe, the avatar created by osNpcCreate(), stands at <143.6586, 145.6026, 23.97617>. My avatar with the attached object stands next to her. Then I enter "/10 movetarget", and Jane Doe moves to <125.646, 127.8072, 23.99928>. The movement vector on XY plain is <-18.0126, -17.7954>, while it is set to <-10,-10> in the code. Then I enter "/10 move", the avatar moves to <143.5855, 145.9399, 23.99706>. The movement vector on XY plain is <17.9395, 18.1327>, while it should be <10, 10>. I've also tested movetargetnoland and movetargetwalk, it could have the same problem. However, the real weird thing is, among my many experiments, sometimes the avatar moves as described above all the time and sometimes as I keep testing without changing anything, the avatar tends to move correctly. That is, for the first a couple of times the avatar moves further than the distance set in code, then she is able to move <10, 10> every time. It seems that these functions are not working stably. I did the experiment with two situations: the object is attached to my avatar and not. As far as my testing goes, the result of attaching the object to avatar is better, but the over-movement problem still exists.
Additional InformationThe following is the script that I'm using.
key npc;
default
{
    state_entry()
    {
        llListen(10,"",NULL_KEY,"");
    }
 
    listen(integer channel, string name, key id, string msg)
    {
        if (msg != "")
        {
            if (msg == "create")
            {
                osOwnerSaveAppearance("appearance");
                npc = osNpcCreate("Jane", "Doe", <135, 135, 24>, "appearance");
            }
            else if (msg == "remove" && npc != NULL_KEY)
            {
                osNpcSay(npc, "You will pay for this with your liiiiiivvveeessss!!!.....");
                osNpcRemove (npc);
            }
            else if (msg == "say" && npc != NULL_KEY)
            {
                osNpcSay(npc, "I am your!!");
            }
            else if (msg == "move" && npc != NULL_KEY)
            {
                osNpcMoveTo(npc, llGetPos() + <10,10,0>);
            }
            else if (msg == "movetarget" && npc != NULL_KEY)
            {
                osNpcMoveToTarget(npc, llGetPos() + <-10,-10,5>, OS_NPC_FLY|OS_NPC_LAND_AT_TARGET);
            }
            else if (msg == "movetargetnoland" && npc != NULL_KEY)
            {
                osNpcMoveToTarget(npc, llGetPos() + <10,10,5>, OS_NPC_FLY);
            }
            else if (msg == "movetargetwalk" && npc != NULL_KEY)
            {
                osNpcMoveToTarget(npc, llGetPos() + <10,10,0>, OS_NPC_NO_FLY);
            }
            else if (msg == "rot" && npc != NULL_KEY)
            {
                vector xyz_angles = <0,0,45>; // This is to define a 45 degree change
                vector angles_in_radians = xyz_angles * DEG_TO_RAD; // Change to Radians
                rotation rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation
                rotation rot = osNpcGetRot(npc);
                osNpcSetRot(npc, rot * rot_xyzq);
            }
            else if (msg == "animate" && npc != NULL_KEY)
            {
                osAvatarPlayAnimation(npc, "handshake");
                llSleep(3);
                osAvatarStopAnimation(npc, "handshake");
            }
            else if (msg == "save" && npc != NULL_KEY)
            {
                osNpcSaveAppearance(npc, "appearance");
            }
            else if (msg == "load" && npc != NULL_KEY)
            {
                osNpcLoadAppearance(npc, "appearance");
            }
            else if (msg == "clone")
            {
                osOwnerSaveAppearance("appearance");
            }
            else if (msg == "stop" && npc != NULL_KEY)
            {
                osNpcStopMoveToTarget(npc);
            }
            else
            {
                llOwnerSay("I don't understand [" + msg + "]");
            }
        }
    }
}
TagsNo tags attached.
Git Revision or version number17dab72 2011-08-30 08:44:28 -0700
Run ModeStandalone (1 Region)
Physics EngineBasicPhysics
Script Engine
EnvironmentMono / Windows
Mono Versiontrunk
ViewerSecond Life 3.0.0
Attached Files

- Relationships

-  Notes
(0019925)
casiasfalta (reporter)
2011-09-12 11:54

I have had better luck if i use osNpcGetPos() rather then llGetPos() to let the script know where to start.
(0019997)
justincc (administrator)
2011-09-21 14:24

I'm surprised you're seeing this level of variation - in my internal tests the max variation was about 1 unit in any vector, though I accept there may well be bugs here.

Unfortunately, there's a complex interaction with the physics code going on which makes it very difficult to stop the avatar in an exact spot. This might not be addressed in time for the next release.

In the meantime, I would suggest using the OSSL teleport commands if possible. Unlike movement, these remove and recreate the physics actor so this doesn't interfere with placement.

- Issue History
Date Modified Username Field Change
2011-09-06 08:29 Quin3y New Issue
2011-09-06 08:29 Quin3y Git Revision => 17dab72 2011-08-30 08:44:28 -0700
2011-09-06 08:29 Quin3y Run Mode => Standalone (1 Region)
2011-09-06 08:29 Quin3y Physics Engine => BasicPhysics
2011-09-06 08:29 Quin3y Environment => Mono / Windows
2011-09-06 08:29 Quin3y Mono Version => trunk
2011-09-06 08:29 Quin3y Viewer => Second Life 3.0.0
2011-09-12 11:54 casiasfalta Note Added: 0019925
2011-09-21 14:24 justincc Note Added: 0019997


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker