Jump to content

Orbiting object (script help)


JennferKoontz
 Share

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

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

Recommended Posts

I am working on an animesh project, think of and animated dog walking in a circle, I have pieced together an orbiting script to get the "Dog" to move around a point in space, however the "Dog" is rotating on it's z axis (slow spin) as well. I need the "dog" to remain moving forward without the spin. Also rotation setting should remain x= 0, y=0 ,              z= movement in space so dog is always facing forward.

 

here is what I have so far: (Credit goes to Kira for the base of the script.) As always your help is greatly appreciated!

//////////////////////////////////////////////////////////
// [K] Kira Komarov - 2011, License: GPLv3              //
// Please see: http://www.gnu.org/licenses/gpl.html     //
// for legal details, rights of fair usage and          //
// the disclaimer and warranty conditions.              //
//////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
//                  CONFIGURATION                       //
//////////////////////////////////////////////////////////
// How precise corners are?
float DEFINITION = 0.1;
// What range from the owner in 
// meters?
float RADIUS = 10; // meters
// How precise should the drift 
// towards the target be?
float TARGET_AFFINITY = 0.8; // meters
// When will the object consider 
// it has reached the target?
float TARGET_DAMPENING = 0.5;
//////////////////////////////////////////////////////////
//                      INTERNALS                       //
//////////////////////////////////////////////////////////
vector dPos = <70.90073, 126.89610, 2501.30200>;
float a = PI;
float b = PI;
 
vector nextPos(vector iPos) {
    // Circle Rotation
    if(a >= TWO_PI) a=0; if(b >= TWO_PI) b=0;
    return iPos + <RADIUS *  llCos(a+=DEFINITION), RADIUS * llSin(b+=DEFINITION), 0>;
}
 
moveTo(vector position) {
    llTargetRemove(_targetID);
    _targetID = llTarget(position, TARGET_AFFINITY);
    
    llLookAt( <70.90073, 126.89610, 2501.30200> + <0.0, 0.0, 90.0>, 1.0, 1.0 );
    llTargetOmega(<0.0,0.0,0.0>*llGetRot(),1.1,0.01);
    llMoveToTarget(position, TARGET_DAMPENING);    
}
 
key _owner = NULL_KEY;
integer _targetID = 0;
 
default
{
    state_entry() {
        llSetStatus(STATUS_PHYSICS, FALSE);
        _owner = llGetOwner();
        llSensorRepeat("", _owner, AGENT, 20, TWO_PI, (1.2-llGetRegionTimeDilation()));
        _targetID = 0;
    }
 
    sensor(integer num) {
        dPos = <70.90073, 126.89610, 2501.30200>;
    }
    no_sensor() {
        llSetStatus(STATUS_PHYSICS, FALSE);
    }
 
    touch_start(integer total_number)
    {
        llSetStatus(STATUS_PHYSICS, TRUE);
        llSetForce(<0,0,9.81> * llGetMass(), 0);
        dPos = <70.90073, 126.89610, 2501.30200>;
        moveTo(nextPos(dPos));
    }
    at_target(integer tnum, vector targetpos, vector ourpos) {
        if(tnum != _targetID) return;
        moveTo(nextPos(dPos));
    }
    on_rez(integer param) {
        llSetStatus(STATUS_PHYSICS, FALSE);
        _owner = llGetOwner();
    }
    changed(integer change) {
        if(change & CHANGED_OWNER)
            _owner = llGetOwner();
    }
}

//End of script

Link to comment
Share on other sites

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