Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rocket script

Naratso Khan
Registered User
Join date: 11 Mar 2004
Posts: 13
08-03-2004 00:06
i have constructed a spaceship, with particle scripts and texturing, but the part that has been eluding me is i cannot, for some reason, get a script to make it shoot straight up, and then fall back down, not flying , just straight up and down. if someone could post a script that could help me, i would appreciate it.


Attempt #1

default
{
state_entry()
{
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
llSensorRepeat("", llGetOwner(), AGENT, 255, PI, .1);
}
sensor(integer iNum)
{
vector pos = llDetectedPos(0) - <0,0,20000>;
llMoveToTarget(pos, 0.1);
}
}


i've done it also using llMoveToTarget, but it doesnt want to work when i'm sitting inside it.
Relee Baysklef
Irresistable Squirrel
Join date: 18 Sep 2003
Posts: 360
Re: Rocket script
08-03-2004 10:01
From: someone
Originally posted by Naratso Khan
i have constructed a spaceship, with particle scripts and texturing, but the part that has been eluding me is i cannot, for some reason, get a script to make it shoot straight up, and then fall back down, not flying , just straight up and down. if someone could post a script that could help me, i would appreciate it.


Attempt #1

default
{
state_entry()
{
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
llSensorRepeat("", llGetOwner(), AGENT, 255, PI, .1);
}
sensor(integer iNum)
{
vector pos = llDetectedPos(0) - <0,0,20000>;
llMoveToTarget(pos, 0.1);
}
}


i've done it also using llMoveToTarget, but it doesnt want to work when i'm sitting inside it.




Straight up, then straight down? No drifting?

Going up and down with drifting is easier. If you don't want it to drift then you'll need to use llMoveToTarget();

There is a bug/feature in llMoveToTarget that stops it from moving to any target more than a set distance away. I think it's 50 meters but I haven't measured it accurately.


Anyway if you set up a loop you can fly straight up, but it's not as realistic as using llSetForce(); if you ask me. :P


I've really got to reccomend against using a sensor for this, also.


CODE


integer godown = FALSE;


default
{
state_entry()
{
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
}

touch_start(integer num_detected)
{
llSetTimerEvent(1);
}

timer()
{
vector currentpos = llGetPos();
if(!godown) currentpos.z += 10;
else currentpos.z -= 10;
llMoveToTarget(currentpos, 2);
if(currentpos.z > 500) godown = TRUE;
if((currentpos.z < (llGround() + 10)) && godown) llStopMoveToTarget();
}
}







Phew. That should work for ya, unless I made some syntax errors. If nothing else it should give you an idea of how I might do it, if I wasn't going to use llSetForce();
_____________________
-- Relee the Squirrel --
Naratso Khan
Registered User
Join date: 11 Mar 2004
Posts: 13
08-03-2004 12:44
there seems to be a problem in the script. A type mismatch in this line:

if((currentpos.z < (llGround() + 10)) && godown) llStopMoveToTarget();

And also, you said that there is a way to use llSetForce, i have already attempted using this, and with no success, but i may have had scripting problems, so if you could consider that, i would appreciate.
Anu Statosky
Registered User
Join date: 15 Mar 2004
Posts: 20
08-03-2004 19:58
Try something like this, it is along the lines of what I used in my rocket ship:

float mass = llGetMass();
float gravityplus = 15.8;
llSetForce(mass * <0, 0, gravityplus>, FALSE);

Just make sure to turn off the force or you will go off world.
Rysidian Rubio
Ruby Red Head
Join date: 14 Jan 2004
Posts: 263
08-03-2004 21:21
You could just apply an upward force for a set ammount of time, then take the force away and the rocket will fall.

eg:
CODE

default
{

state_entry()
{
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
}

touch_start(integer num_detected)
{
llSetForce(<0,0,20>, FALSE);
llSetTimerEvent(30);
}

timer()
{
llSetForce(<0,0,0>,FALSE);
llSetTimerEvent(0);
}
}