Jump to content

how can i make my prim look at me with his face before he movetotarget


Simoo0
 Share

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

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

Recommended Posts

i have a prim with sensor which can follow me when i call it ,it uses RotLookAt to look in the same rotaion of my AVI but it comes with its back if i look at it , so i used a rotation offset in z by 180 degree to make it comes to me but if i call it while my back to this prim ,it comes with back cant solve this anyone can help i appreciate :)

this example will be used for pet cat

this is script in object :

////

rotation rot_xyzq;
oppisiteRot()
{
    rotation rot = llDetectedRot(0);
                    vector xyz_angles = <0,0,180>; // This is to define a 1 degree change
        vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians
        rot_xyzq = llEuler2Rot(angles_in_radians);
     llRotLookAt(rot*rot_xyzq, .1 , 1);    
}
default
{
    state_entry()
    {

          
        llSetStatus(STATUS_PHYSICS, TRUE);
 

    }
     touch_start(integer num_detected)
    {      vector pos = llGetPos();
     

        // Look for owner within 20 meters in 360 degree arc every 1 seconds.
        llSensorRepeat("", llGetOwner(), AGENT, 20.0, PI,1.0);
        }
    sensor(integer total_number)
    {
         oppisiteRot();
            vector pos = llDetectedPos(0);
        // Offset back one meter in X and up one meter in Z based on world coordinates.
        vector offset =<-1,0,1>;
//        offset = offset*llDetectedRot(0);  //Adding this line will orient the follower relative to the owner's position.
        pos+=offset;
        llMoveToTarget(pos,0.4);    
    }
}

Link to comment
Share on other sites

You are trying to use llDetectedRot() outside of an event that has detections, you are better off moving that statement into the sensor event and then either passing the detected rotation to the other function opposite_rot as an argument, or else assign i to a global variable.

 

In the sensor event, oppisite_Rot(llDetectedRot(0)); will do it, then alter oppisiteRot() to be

oppisiteRot(rotation foundRot)

 

should help you,

A possible simplification:

In addition, you are calculating a reversat rotation in that function every ttime it is called, I would suggest moving the lines that assign the vector value <0,0,180> and then convert it to radians and finally to a rot from Euler into state_entry, so that the calculations are done once only and the rot_xyz then effectively becomes a constant for the rest of the script. Once you've done that, the remaining calculation or spinning the object through 180 degrees is a one-liner and so could be put back inside he sensor event.

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

6 hours ago, Innula Zenovka said:

Chalice Yao over the road.

llSetRot(llRotBetween(<1,0,0>,llVecNorm(<fDistance,0,vTarget.z - vPos.z>)) * llRotBetween(<1,0,0>,llVecNorm(<vTarget.x - vPos.x,vTarget.y - vPos.y,0>)));

 

The vec-norms in her code are almost all unnecessary, as the LLfunctions she uses them in all do normalization for you anyway,

vector diff = targetPos - llGetPos();
llSetRot(
  llRotBetween(<1,0,0>,<llVecMag(<diff.x,diff.y,0>),0,diff.z>) *
  llRotBetween(<1,0,0>,<diff.x,diff.y,0>)
);

should work (untested) and be a bit more efficient.

As for inefficient but easy to use solutions, from my rotation post:

Quote
rotation YPR2Rot(vector v) // Yaw Pitch Roll
{   return
        <llSin(v.z/2),0,0,llCos(v.z/2)> *
        <0,llSin(v.y/2),0,llCos(v.y/2)> *
        <0,0,llSin(v.x/2),llCos(v.x/2)> ;
}
rotation uVectorRoll2Rot(vector v,float r)
{   return YPR2Rot(<llAtan2(v.y,v.x),-llAtan2(v.z,llVecMag(<v.x,v.y,0>)),r>);
}

could be used as llSetRot(uVectorRoll2Rot(targetPos-llGetPos(),0)); which would also give you control over how much your thing is 'rolling', or tilting side to side.

  • Thanks 1
Link to comment
Share on other sites

18 hours ago, Quistess Alpha said:

The vec-norms in her code are almost all unnecessary, as the LLfunctions she uses them in all do normalization for you anyway,

vector diff = targetPos - llGetPos();
llSetRot(
  llRotBetween(<1,0,0>,<llVecMag(<diff.x,diff.y,0>),0,diff.z>) *
  llRotBetween(<1,0,0>,<diff.x,diff.y,0>)
);

should work (untested) and be a bit more efficient.

As for inefficient but easy to use solutions, from my rotation post:

could be used as llSetRot(uVectorRoll2Rot(targetPos-llGetPos(),0)); which would also give you control over how much your thing is 'rolling', or tilting side to side.

Thanks.   What does the float "r" represent in your userfunction uVectorRoll2Rot?

Link to comment
Share on other sites

5 hours ago, Innula Zenovka said:

What does the float "r" represent in your userfunction uVectorRoll2Rot?

It represents the 'roll' of the object,

So like if your thing is a puppy head and you want it looking at you sideways rather than head on . . .

(assuming like all well built things in SL its x-axis is forward)

r ~=  PI*0.25 :

Finally, the reason for why do dogs tilt their heads.

r ~= 0:

The "Pit Bull" Myth - Straight Dope Message Board

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1056 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...