Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Little More Help Please???

Candy Ferguson
Registered User
Join date: 22 Jun 2006
Posts: 20
04-20-2008 02:08
Hi is there a way to control the llSetPos(llGetPos() + <0,0,5>;); call to control how long it takes to move to the end pos. Say for example if you wanted an object to move slowly to the height of 5m over say ten seconds??

Thanks
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
get physical
04-20-2008 03:32
llSetPos() is for non physical objects and there is no way you can control the speed of the object.

But for physical objects you can:

llMoveToTarget( vector Point, float tau); // will move to Point, SIM coordinates, in time tau seconds

happy scripting
_____________________
From Studio Dora
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
04-20-2008 07:51
Now that you are getting into physical movement it gets a little bit more complicated. If an object is top heavy or oddly shaped then it will have a tendency to rollover when you set it physical just as it would in RL. To counteract that you can use a llSetStatus call so that it won't roll on any of it's axis. Also once llMoveToTarget is called it stays active until it is stopped. Finally, in most cases I set the item physical ONLY when I am moving it.

I am not much for adding a lot of explanations into the body of my scripts so if there is anything you don't understand, don't hesitate to ask:

CODE
integer up = TRUE;
integer targetID;
vector pos;

default
{
state_entry()
{
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, 0);
}
touch_start(integer total_number)
{
pos = llGetPos();
llSetStatus(STATUS_PHYSICS, 1);
if(up){
pos.z += 5.;
targetID = llTarget(pos, .2);
llMoveToTarget(pos, 10.0);
up = !up;
}
else{
pos.z -= 5.;
targetID = llTarget(pos, .2);
llMoveToTarget(pos, 10.0);
up = !up;
}
}
at_target(integer tnum, vector targetpos, vector ourpos)
{
llTargetRemove(targetID);
llStopMoveToTarget();
llSetStatus(STATUS_PHYSICS, 0);
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Kidd Krasner
Registered User
Join date: 1 Jan 2007
Posts: 1,938
04-20-2008 22:51
From: Dora Gustafson
llSetPos() is for non physical objects and there is no way you can control the speed of the object.


Not directly, but you could do the vector arithmetic yourself, and write a loop that moves the object a bit, sleeps, moves a bit more, etc. Depending on how often and how far it's moving, this may or may not be a good idea, lag-wise.
Candy Ferguson
Registered User
Join date: 22 Jun 2006
Posts: 20
Thanks a heap :)
04-21-2008 01:43
Thank you to all of you I will try this...
Candy Ferguson
Registered User
Join date: 22 Jun 2006
Posts: 20
This Works Well However
04-21-2008 02:27
It seems I can only make the object move a maximum of 64m is there a way to make it move a larger distance please???
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
04-21-2008 03:58
read all about it here: http://www.lslwiki.net/lslwiki/wakka.php?wakka=dynamics
if you don't find answers here the links on the page will certainly take you where they are.

Maybe the 'Warp' hack is something for you? see: http://www.lslwiki.net/lslwiki/wakka.php?wakka=LibraryWarpPos
(but that is for non physical objects)

happy scripting
_____________________
From Studio Dora
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
04-21-2008 04:02
From: Candy Ferguson
It seems I can only make the object move a maximum of 64m is there a way to make it move a larger distance please???

AHHHHH! Well yes you can but this has now gone from basic non-physical movement through physical intermediate movement to advanced movement! LOL

This evening I can waaaaay simplify this but for now here is a peek at my physics TP which has no limits. You could even specify a target that is 100,000 meters up. Don't be discouraged when you look at it. Important parts are the not_at_target, at_target and timer events:

CODE
// "Physics TP.esl"

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Physics TP V1.2
// "Feb 11 2008", "11:08:39"
// Creator: Jesse Barnett
// Released into the Public Domain
//////////////////////////////////////////////////////////////////////////////////////////////////////


vector target;

default {
on_rez(integer start_param) {
llListen(start_param, "", "", "");
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
llSetText("Touch to ascend", <0, 0, 0 >, 1.0);
}
state_entry() {
llSetObjectName("Physics TP");
}
listen(integer channel, string name, key id, string message) {
target = (vector) message;
}
changed(integer change) {
if (change & CHANGED_LINK) {
key av = llAvatarOnSitTarget();
if (av) {
llSetStatus(STATUS_PHYSICS, TRUE);
llTarget(target, 50);
}
else {
llDie();
}
}
}
not_at_target() {
vector impulse = target - llGetPos();
llApplyImpulse(llGetMass() * impulse, FALSE);
}
at_target(integer ascend, vector target, vector cPos) {
llTargetRemove(ascend);
llMoveToTarget(target, 0.5);
llSetTimerEvent(5.0);
}
timer() {
if (llVecDist(llGetPos(), target) < 0.01) {
llStopMoveToTarget();
llApplyImpulse(-llGetMass() * llGetVel(), FALSE);
llSetStatus(STATUS_PHYSICS, FALSE);
}
}
}


I'll explain it in more detail later unless someone else want's to jump in here.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
04-21-2008 16:04
Thought your name rang a bell, you are the Rocket Girl!!!!!! So you were already playing with some physics movement in the form of llSetForce. In this case thou, you can see that it isn't just one single LLFunction that controls the movement but a handful working together. It gets kind of confusing looking at the wiki to see how these interact in this case. So I commented this script & hope it helps (I hate commenting :) Takes me longer to comment then to write the script :rolleyes: )You can play with the different values where I marked; ADJUST HERE

CODE

vector target;

default {
state_entry() {
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
target = llGetPos();
target.z += 100;//You could also specify just a vector in the sim ADJUST HERE
//as a target such as <26, 37, 760> etc but for now it will just move straight up
//100 meters from the location this prim is
}
touch_start(integer n) {
llSetStatus(STATUS_PHYSICS, TRUE);
llTarget(target, 5);//This will trigger the at_target even when it is 5 meters away. ADJUST HERE
//The faster you are traveling, the more you need to increase this distance.
}
not_at_target() {
vector impulse = <0,0,1>;//How many meters per second per axis ADJUST HERE
llApplyImpulse(llGetMass() * impulse, FALSE);// The impulse when corrected with llGetMass translates directly
//into meters per second. So in this case it will apply an impulse of 1 meters per second on the z axis.
//If you want to move down then just redefine the target and apply a negative impulse on the z axis
}
at_target(integer ascend, vector target, vector cPos) {
llTargetRemove(ascend);//This removes the target and then
llMoveToTarget(target, 0.5);//redefines it as just 1/2 meters aways here ADJUST HERE
llSetTimerEvent(3.0);//and gives it 3 seconds to move that distance ADJUST HERE
//Set according to about how long it takes to move that distance
}
timer() {
if (llVecDist(llGetPos(), target) < 0.01) {
llStopMoveToTarget();//removes the target
llApplyImpulse(-llGetMass() * llGetVel(), FALSE);//applies an exact counterforce to bring
//the object ot a dead stop
llSetStatus(STATUS_PHYSICS, FALSE);
}
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Candy Ferguson
Registered User
Join date: 22 Jun 2006
Posts: 20
Thank you Jesse :) and everyone
04-22-2008 01:39
As I am still a beginner I really appreciate all your help thank you people!!!