Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

more movement questions

mrbarcode Aeon
Registered User
Join date: 4 Aug 2008
Posts: 11
11-07-2008 19:03
I'm wanting to make a beacon and an object that can move to the object using llApplyImpulse. I got the beacon that is using llRegionSay (I want the object to move all over the sim). I'm having problems giving the vector coordinates to the object to move though. It's listening on the channel it knows what to do once it gets the vector I just dont know how to give it the coords. Can you help me?
Cappy Frantisek
Open Source is the Devil!
Join date: 27 Oct 2006
Posts: 400
11-08-2008 01:28
From: mrbarcode Aeon
I'm wanting to make a beacon and an object that can move to the object using llApplyImpulse. I got the beacon that is using llRegionSay (I want the object to move all over the sim). I'm having problems giving the vector coordinates to the object to move though. It's listening on the channel it knows what to do once it gets the vector I just dont know how to give it the coords. Can you help me?


If your passing the coordinates through the listen, I would cast the coordinate vector to a string and then before you use it cast it back to a vector.
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
11-08-2008 06:35
There is another way. Let the beacon just say "Beacon" (for example).

And in the moving object:

listen(integer channel, string name, key id, string msg)
{
if (msg == "Beacon";)
{
llListenRemove(Handle);
llRegionSay(Channel, "STFU";); // Eventually...
// The useful line:
BeaconPos = llList2Vector(llGetObjectDetails(id, [OBJECT_POS]), 0);
}
}

To move to a target with llApplyImpulse(), I'd use something like:

timer()
{
vector pos = llGetPos();
llApplyImpulse(llVecNorm(TargetPos, pos) * llVecMag(TargetPos - pos), FALSE);
}

But don't trust me on this one... Yesterday I launched a supersonic object that must be orbiting around SL as we speak. :P
mrbarcode Aeon
Registered User
Join date: 4 Aug 2008
Posts: 11
11-08-2008 07:08
>Kaluura Boa

That is a hell of a lot simpler. I'll test it out in a bit and tell you how it goes
mrbarcode Aeon
Registered User
Join date: 4 Aug 2008
Posts: 11
11-08-2008 08:12
From: mrbarcode Aeon
>Kaluura Boa

That is a hell of a lot simpler. I'll test it out in a bit and tell you how it goes



Well your applyImpule line is giving me a script error and when I try to fix it the object will start hopping in a straight line when it gets the command
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
11-08-2008 23:56
llVecNorm() takes only one argument. With llApplyImpulse() you are adding to the object's MOMENTUM (velocity times mass). I'd suggest something more like:

CODE

timer()
{
vector currentVel = llGetVel();
vector desiredVel = speed*llVecNorm(targetPos-llGetPos);
vector dp = llGetMass()*(desiredVel-currentVel);
llApplyImpulse(dp, FALSE);
}


Gravity may still affect your path unless you've set a force or buoyancy, so unless the speeds and times at which you are operating are such that any acceleration due to gravity is insignificant you'll have to consider ballistic trajectories.

Note though that llMoveToTarget() may do what you want in a simpler and more efficient manner. All you need for that function is a target position and a timeframe for exponential damping to that position. See http://www.lslwiki.net/lslwiki/wakka.php?wakka=llMoveToTarget
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
11-10-2008 01:28
No idea what I was thinking of... Here is what would be syntactically correct:

timer()
{
vector offset = TargetPos - llGetPos();
llApplyImpulse(llVecNorm(offset) * llVecMag(offset), FALSE);
}

Any way, follow Heewee advice... I never use llApplyImpulse() for anything but kicking objects away. llMoveToTarget() is the most logical choice to reach a destination.