These forums are CLOSED. Please visit the new forums HERE
Object flying around a central point within a radius |
|
|
Itchy Stiglitz
Mostly Harmless
Join date: 24 Apr 2006
Posts: 23
|
05-31-2006 08:37
Has anyone had luck getting an object to fly around a centeral point within a radus?
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
05-31-2006 08:49
I think a little more information is required, are you looking to make something which follows a path on the surface of a sphere (constant radius), or is restricted to move within a sphere (r = 0 to radius)?
If you wish something to spin about an axis you might be best using llTargetOmega (see http://secondlife.com/badgeo/wakka.php?wakka=llTargetOmega ) although this requires that you have the root prim at the centre of rotation and linking distances may be a problem for large radii. Perhaps you're using a llSetPos movement? If so a check along the lines of: CODE
Post some more details of your problem and we'll try and assist. |
|
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
|
05-31-2006 09:20
If not llTargetOmega, you're probably going to need to use sines and cosines to get the locations of the circle. I made something like this, I'll post the code when SL comes back online.
_____________________
|
|
Itchy Stiglitz
Mostly Harmless
Join date: 24 Apr 2006
Posts: 23
|
05-31-2006 09:44
What I have is a cube that flys up and says hi when an av comes near. I would like it to fly around in a circle around it's current location sort of like a loop/hover, to make it seem more playful. So my central point would be it's current location in space or a set distance from it's current point. I could use an invisable sphere as my central point but I wonder if there is a cleaner way?
|
|
Mendacio Montgomery
Registered User
Join date: 12 May 2006
Posts: 13
|
05-31-2006 09:55
Itchy,
Ok here's the math in pseudo-code... vector origin = <X, Y, Z>; // provide your origin coords here float radius = R; // provide your radius here float theta = 0; float thetaIncr = (2*PI / n); // choose n as the number of steps in the circle doit() { ...while (orbiting) ...{ ......for (theta = 0; theta < (2*PI); theta += thetaIncr) ......{ .........float x = R * cos(theta); .........float y = R * sin(theta); .........vector newPos = origin + <x, y, 0>; .........travelTo(newPos); ......} ...} } travelTo(newPos) { ...while(objectPos != newPos) ...{ ......moveObjectTo(destination); // over time or instantaneously or whatever ...} } |
|
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
|
05-31-2006 10:10
or you can use the formula for a sphere, x^2 + y^2 + z^2 = r^2. where r is the radius.. up to you if you want to use geometry or trig.
|
|
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
|
05-31-2006 10:30
I did this sort of thing by choosing an offset from the rotation point (say <1, 0, 0> for a one-meter circle), and just using a timer to multiply that by an incrementing rotation, setting the new position with llMoveToTarget().
Something like this (though I haven't tested it in-world since the grid is down): CODE // What axis do you want to rotate around? This is, of course, a version using Physics. A non-physical version should function almost exactly the same, though. ![]() _____________________
- Making everyone's day just a little more surreal -
Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?" |
|
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
|
05-31-2006 11:12
Here's my code. It will make the object rotate around the owner.
CODE
_____________________
|
|
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
|
05-31-2006 13:05
If you wish something to spin about an axis you might be best using llTargetOmega (see http://secondlife.com/badgeo/wakka.php?wakka=llTargetOmega ) although this requires that you have the root prim at the centre of rotation and linking distances may be a problem for large radii. _____________________
|
|
Itchy Stiglitz
Mostly Harmless
Join date: 24 Apr 2006
Posts: 23
|
06-01-2006 08:15
Thank you all for the help. This goes a long way toward me understanding how LS works. You guys are awesome!
|