Jump to content

LSL programmed animation (npc)


Veity
 Share

You are about to reply to a thread that has been inactive for 3550 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hey there, new to the forums so im not to sure if this is the place to post this but thought i'd try anyway. I am a regular programmer but new to lsl scripting. I am trying to create a script to animate npc's so far its very simple, it just moves and rotates an object (in this case the upper part of an arm).

 

The problem is im having difficulties getting the rotations to work. Ive created a test where the rotation should deliberatly not change however when i touch the object in question it rotates slightly and i cannot figure out why, any help would be greatly appreciated :-)

 

vector startPosition;
vector endPosition;

rotation startRotation;
rotation endRotation;

string objectState;

default
{
    state_entry()
    {
      startRotation = llGetRot();
      
      //endRotation = llEuler2Rot(<5, 68, 327> * DEG_TO_RAD );
      
      startPosition = llGetPos();
      //endPosition = <107.45774, 138.46310, 3801.77515>;
      
      objectState = "start";
    }

    touch_start(integer total_number)
    {
      if(objectState == "start")//
      {
         llSetPos(startPosition);
         llSetRot(llEuler2Rot(<startRotation.x, startRotation.y, startRotation.z> * DEG_TO_RAD ));

         objectState = "end";
      }
      else if(objectState == "end")
      {
         llSetPos(startPosition);
         llSetRot(startRotation);
         
         objectState = "start";
      }
      llSay(0, objectState);
    }
}

 

Link to comment
Share on other sites

For starters, you are rotating the arm in a regional frame of reference instead of a local frame.  When you're dealing with child prims, you'll almost always want to rotate them with respect to the root prim.  Rotations can be a bear until you get used to them.  Take a good look (the first of many) at

http://wiki.secondlife.com/wiki/Rotation

and

http://wiki.secondlife.com/wiki/User:Void_Singer/Rotations

In your case, you'll want to get the initial local rotation of the arm with llList2Rot(llGetLinkPrimitiveParams(link_no,[PRIM_ROT_LOCAL]),0);

You'll also want to work with local positions, not regional ones.

ETA:  If you are making a NPC, you may also want to consider using a canned routine like Puppetteer

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3550 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...