Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Making my planet orbit

AlexABELTIME Blecher
Registered User
Join date: 4 Jun 2008
Posts: 6
06-04-2008 10:57
i am looking for some tips (or possibly a written script, would be very helpful) to help with making my planet system. I have created a couple of planets, here is thier scripts:

float speed = 0.0;
default
{
state_entry()
{
llSay(0, "I am Orbiter. Touch to Spin me!";);
}
touch_start(integer total_number)
{
if (speed > 20.0) speed = 0.0;
speed ++;
llTargetOmega(<0,1,0>, speed, 0.1);
}
}

i am looking to find a way to make them orbit around each other, possibly resembling something like a solar system. I want to make them communicate with each other as well, so if they get to close to each other, they will move out of the way. or some other form of communication. Anything wiill help, a written script would be VERY appriciated. Thanks
Welleran Kanto
Registered User
Join date: 15 Mar 2008
Posts: 64
06-04-2008 11:18
A quick fix: since you have rotation of an object about its *own* center already... Link your planet to a transparent disk. Put a simple rotation script on the disk. Use a "totally clear" texture to make the disk invisible. When you link, link the disk last, so that it's the "mother" object. And let it spin....
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
06-04-2008 11:52
You don't even need the disk, just link each planet to the central "sun" and put the roatate script in there. The only downside is that the planets will always be in the same relative positions and the outermost will be orbiting faster then they would in a RL situation. I do have an orbit about an object script in world and I will send it to you when I am on line later.

I couldn't find you in search so here is the script. It will orbit about the rez point or about an object named Hub if it exisits.

CODE

vector root;
float ellipse_x;
float ellipse_y;
float angle = 0;

string axis_name = "Hub";

default {

on_rez( integer Parameter ) { llResetScript(); }

state_entry() {

root = llGetPos(); // default axis is around myself (sensor will update)

ellipse_x = 3.0; // r_max these will control the size and shape of the elipse
ellipse_y = 2.0; // r_min

llSetTimerEvent( 0.2 ); // or more depending how smooth and fast it's to be

// non moving target
llSensor( axis_name, NULL_KEY, PASSIVE | ACTIVE, 20.0, PI ); // 20m range
// moving target
// llSensorRepeat(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range
}

timer() {

angle += 5.0 * DEG_TO_RAD; if( angle >= TWO_PI ) angle -= TWO_PI;
float x = ellipse_x * llCos(angle);
float y = ellipse_y * llSin(angle);
llSetPrimitiveParams( [ PRIM_POSITION, root + <x, y, 0>, PRIM_ROTATION, llEuler2Rot( <0.0, 0.0, angle> ) ] );
}

sensor(integer num_detected)
{
root = llDetectedPos(0);
}

no_sensor()
{
llWhisper(0, axis_name + " not found.");
llSensorRemove();
}

}
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
06-04-2008 13:12
offset rotation is explained in the sls wiki.
Jasperodus Ulysses
Registered User
Join date: 25 May 2008
Posts: 9
06-04-2008 20:44
Sure, but my way lets you adjust the relative rotation speeds of each planet's orbital disk. I think that's worth a prim.
AlexABELTIME Blecher
Registered User
Join date: 4 Jun 2008
Posts: 6
06-06-2008 10:49
From: Ravanne Sullivan
You don't even need the disk, just link each planet to the central "sun" and put the roatate script in there. The only downside is that the planets will always be in the same relative positions and the outermost will be orbiting faster then they would in a RL situation. I do have an orbit about an object script in world and I will send it to you when I am on line later.

I couldn't find you in search so here is the script. It will orbit about the rez point or about an object named Hub if it exisits.

CODE

vector root;
float ellipse_x;
float ellipse_y;
float angle = 0;

string axis_name = "Hub";

default {

on_rez( integer Parameter ) { llResetScript(); }

state_entry() {

root = llGetPos(); // default axis is around myself (sensor will update)

ellipse_x = 3.0; // r_max these will control the size and shape of the elipse
ellipse_y = 2.0; // r_min

llSetTimerEvent( 0.2 ); // or more depending how smooth and fast it's to be

// non moving target
llSensor( axis_name, NULL_KEY, PASSIVE | ACTIVE, 20.0, PI ); // 20m range
// moving target
// llSensorRepeat(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range
}

timer() {

angle += 5.0 * DEG_TO_RAD; if( angle >= TWO_PI ) angle -= TWO_PI;
float x = ellipse_x * llCos(angle);
float y = ellipse_y * llSin(angle);
llSetPrimitiveParams( [ PRIM_POSITION, root + <x, y, 0>, PRIM_ROTATION, llEuler2Rot( <0.0, 0.0, angle> ) ] );
}

sensor(integer num_detected)
{
root = llDetectedPos(0);
}

no_sensor()
{
llWhisper(0, axis_name + " not found.");
llSensorRemove();
}

}


Its not quite working right. I created a planet to be the center of them and named it Hub, then added the script to it. After i link them together the other planets are not orbiting around accordingly. also is there any way i can incorperate communication into this?

Thanks A LOT btw.
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
06-06-2008 11:31
You don't add that script to the Hub, add it to the planets. The planets should not be linked, they sense the location of the Hub and plot their course around it. Movement may not be as smooth as you like but you can play with the script for different orbit sizes and speeds.
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
AlexABELTIME Blecher
Registered User
Join date: 4 Jun 2008
Posts: 6
06-06-2008 11:40
From: Ravanne Sullivan
You don't add that script to the Hub, add it to the planets. The planets should not be linked, they sense the location of the Hub and plot their course around it. Movement may not be as smooth as you like but you can play with the script for different orbit sizes and speeds.


i see, but now if i move my Hub, the planets dont move with it.

sorry for being such a newbie lol, i'm new to second life.
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
06-06-2008 11:56
They only see the position when the script first starts, you can uncomment the line

// llSensorRepeat(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range

and comment out the line

llSensor( axis_name, NULL_KEY, PASSIVE | ACTIVE, 20.0, PI ); // 20m range

and the script will adjust for a moving Hub

I have put together a quick little solar system demo and if you IM me in game I will send it to you to play with
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
AlexABELTIME Blecher
Registered User
Join date: 4 Jun 2008
Posts: 6
06-07-2008 23:45
err i'm on a private island so in teen second life so i dont think we can communicate there
AlexABELTIME Blecher
Registered User
Join date: 4 Jun 2008
Posts: 6
06-10-2008 14:35
i have a couple more questions.

1. So is there any way to link them together so i can move my general solar system around?
2. How do i make a larger diameter for my orbiting planets?
3. How can i put my spin script into them while they are rotating
4. How can i make them orbit around the central sun in different directions and placing?

Answers to these questions will be GREATLY appreciated, and again, if you can post them here because i cannot come in contact with you guys in second life. Thanks
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
06-10-2008 15:31
From: AlexABELTIME Blecher
i have a couple more questions.

1. So is there any way to link them together so i can move my general solar system around?
2. How do i make a larger diameter for my orbiting planets?
3. How can i put my spin script into them while they are rotating
4. How can i make them orbit around the central sun in different directions and placing?

Answers to these questions will be GREATLY appreciated, and again, if you can post them here because i cannot come in contact with you guys in second life. Thanks


1. Not with the script I posted, each planet orbits on its own.

2. The following lines control the orbit sizes

ellipse_x = 3.0; // r_max these will control the size and shape of the elipse
ellipse_y = 2.0; // r_min

3. Edit this line

llSetPrimitiveParams( [ PRIM_POSITION, root + <x, y, 0>, PRIM_ROTATION, llEuler2Rot( <0.0, 0.0, angle> ) ] );

to this

llSetPrimitiveParams( [ PRIM_POSITION, root + <x, y, 0>, ] );

And drop in your rotation script to the planet

4. These lines control the motion, play with them a bit and see what you get.

angle += 5.0 * DEG_TO_RAD; if( angle >= TWO_PI ) angle -= TWO_PI;
float x = ellipse_x * llCos(angle);
float y = ellipse_y * llSin(angle);
llSetPrimitiveParams( [ PRIM_POSITION, root + <x, y, 0>, PRIM_ROTATION, llEuler2Rot( <0.0, 0.0, angle> ) ] );
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-10-2008 15:57
If you keep everything within 10m of the root prim, you could do away with the sensors and use local positioning of all prims within the link set. That would keep it all linked as one unit, but with the caveat that nothing could move farther than 10m from the center (the limit a linked prim is allowed to move).

If you keep them separate, you may want to experiment with not using primitive params PRIM_POSITION, but instead setting the planets to be physical, and phantom, with bouyancy.
ie
llSetStatus(STATUS_PHYSICS|STATUS_PHANTOM,TRUE);
llSetBuoyancy(1.0); //defy gravity
llMoveToTarget(pos_vector,0.5); //0.5 is a damping time.. adjust it or even calculate it based on your parabola length and rotation speed etc to try and find a way to make it smooth in general for all planets?

You can then use llMoveToTarget with various degrees of Tau to try and achieve some smoother motions along your interpoalted elliptical path.

The gist of the script wouldn't be any different, you'd just be using a different move call, then experimenting with the damping of movetotarget to try and achieve something smoother.
AlexABELTIME Blecher
Registered User
Join date: 4 Jun 2008
Posts: 6
06-10-2008 21:10
ah, 1 more problem. I cannot successfully get my planets to spin while in orbit, i don't get what you mean by "Drop in your rotation script to the planet". I would also like to add some communication into my system. It would be awesome if you guys could cook something up that makes the planets change to a darker shade the closer it comes in contact with the central sun, almost like it is being burnt. Thanks so much for the help so far guys. This is probably my last request.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
06-11-2008 01:22
Communication is simple enough, have all of planet prims llListen to a channel that they can all communicate on (llSay).

Changing shade would just be a case using of llSetColor.

Adding a z axis to the orbit would be nice :)
_____________________
I'm back......
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
07-31-2008 05:37
There's an error, I think, in the llSensorRepeat code for a moving hub...I had to change it from // llSensorRepeat(axis_name, "", 20.0, ACTIVE | PASSIVE, PI, 2.0); // 20m range
to
CODE
 // moving target 
llSensorRepeat(axis_name, NULL_KEY,ACTIVE|PASSIVE, 20.0, PI, 2.0); // 20m range

I'm not sure if the NULL_KEY makes much difference but I'm sure the positioning of 20.0, the range, does.