Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Smooth up and down movement

Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
03-09-2006 23:17
Ok, I am working on writing a script for someone that will move up and down in a steady motion. Unfortunately, I can only get a jerky motion. Another thing i have noticed is that most times, there are several orbs circling the scripted prim whenever it moves.

Here is the script i an working on...
The reason i used llSetPos instead of llMoveToTarget is because i wanted to be able to place the object in midair without it falling (due to physics with move)


//Movement Script
//Copyright Dustin Widget
//2006

string start = "start"; //Command to start the movement.
string stop = "stop"; //Command to stop the movement.
integer channel = 3; //Channel to listen to command on.
float dist = 0.1; //Distance moved from center point.

integer on = FALSE;
integer up = TRUE;
vector pos;
vector pos2;
mover()
{
pos = llGetPos();
if(up)
{
pos2 = pos;
pos2.z = pos2.z + dist;
up = FALSE;
}
else
{
pos2 = pos;
pos2.z = pos2.z - dist;
up = TRUE;
}
llSetPos(pos2);
}

integer listener;
default
{
state_entry()
{
listener = llListen(channel,"",llGetOwner(),"";);
llSetTimerEvent(0.01);
}
on_rez(integer start_param)
{
llListenRemove(listener);
listener = llListen(channel,"",llGetOwner(),"";);
}
timer()
{
if(on)
{
mover();
}
}
listen(integer channel, string name, key id, string msg)
{
if (msg==start)
{
on = TRUE;
}
else if (msg==stop)
{
on = FALSE;
}
}
}
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
03-10-2006 03:26
Essentially llSetPos() will always give you jerky motion, especially if you're riding on it. I have an object (a crab actually) that uses small (about 2.5cm) step non-physical movement that works OK for the appearance of the crab, but then people think of crabs moving in a sort of stop-start motion anyway.

The free hottubs (and I suspect all subsequent versions) use non-physical movement for the water rising, I think that's in 1cm steps but can't get at the scripts from here to check, and it works because you basically only see it from one angle.

Physical movement is really the only way to get genuinely smooth movement however.

If you use llMoveToTarget() the at_target event can be used to kill the physics so it will remain. There are options like setting the hover parameters too, but most people use the switching between physical and non-physical movement if at all possible and if smooth movement is required.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
03-10-2006 03:48
You might want to consider turning the object into a vehicle, if it's too big and runs out of energy when you use physics move functions. This is quite easy, though, as I have discovered, it won't keep moving when nobody is watching it.
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
03-10-2006 03:55
Unfortunately, even physical objects are jerky too, now, as of the last build (1.8.4.7). :/
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
03-10-2006 11:37
llSetBuoyancy(1.0); Should cancel gravity for anything except very very large objects. Don't make it a vehicle unless you have to. Vehicle code even sitting idle puts a load on the physics and event system.
_____________________
Les White
sombish
Join date: 7 Oct 2004
Posts: 163
03-10-2006 14:09
From: Eep Quirk
Unfortunately, even physical objects are jerky too, now, as of the last build (1.8.4.7). :/


since 1.7 really
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
03-10-2006 14:15
makes sense though, it's kind of an object update level of detail.
_____________________
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
03-10-2006 15:41
Ok, thank for your help everyone, I got it working awesome. One final question though, as I stated with the code from above, when it moves, it gets those circling particles. Its not a script or residue from me, its from something i am calling in the code. Is there any way to get rid of that? maybe a blank particle system?

EDIT
-------------
Ok, I tried with blank particle systems, no luck, still have the circling particles....
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
03-10-2006 15:50
You must have an llSay, llChat, or llShout in there you didn't paste cuz that's the only thing I know to cause those circular particles.
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
03-10-2006 16:05
Nope, whats up there is what i first used an still got the particles. No communication of any sort out of the prim.
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
03-10-2006 16:07
Perhaps an error is triggering the particles, then. Object IMs may also cause chat particles.
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
03-10-2006 16:09
I dont think that I have any errors.. Can anyone look at the script up there and tell me why its getting the circling particles?
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
03-10-2006 16:15
I just tried the script but I don't get the particles.
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
03-10-2006 16:26
thats strange... let me try relogging, then creating a new prim with it.

EDIT
--------
Ok, after doing that it works fine now. Thanks everyone!