Thrash Prototype
Registered User
Join date: 24 Aug 2004
Posts: 31
|
09-27-2005 11:16
I was wondering how I would go about making an object orbit (as in move around another object at a different angle besides along just the x y or z axis)?
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
09-27-2005 12:08
There are many ways. One is to simply use LSL's vector arithmetic to do the maths for you: string target = "your object's target name"; float angle; float angle_increment = 0.1; vector offset = <1, 0, 0>; vector axis = <0, 0, 1>;
orbit(vector pos, rotation rot, integer local) { angle = angle + angle_increment; if (angle > TWO_PI) angle = 0.0; if (local) { llMoveToTarget(pos + offset * llAxisAngle2Rot(axis, angle) * rot, 0.4); } else llMoveToTarget(pos + offset * llAxisAngle2Rot(axis, angle), 0.4); }
default { state_entry() { llSetStatus(STATUS_PHYSICS | STATUS_PHANTOM, TRUE); llSetBuoyancy(1.0); llSensorRepeat(target, "", ACTIVE|PASSIVE|SCRIPTED, 60.0, PI, 2.0); }
sensor(integer c) { orbit(llDetectedPos(0), llDetectedRot(0), TRUE); llSleep(0.25); orbit(llDetectedPos(0), llDetectedRot(0), TRUE); llSleep(0.25); orbit(llDetectedPos(0), llDetectedRot(0), TRUE); llSleep(0.25); orbit(llDetectedPos(0), llDetectedRot(0), TRUE); llSleep(0.25); orbit(llDetectedPos(0), llDetectedRot(0), TRUE); llSleep(0.25); orbit(llDetectedPos(0), llDetectedRot(0), TRUE); llSleep(0.25); orbit(llDetectedPos(0), llDetectedRot(0), TRUE); llSleep(0.25); orbit(llDetectedPos(0), llDetectedRot(0), TRUE); } }
This should make your object orbit the other object at distance "offset" around "axis". It will follow the object by updating the target's position every two seconds. I used very simple example vectors here, change those to suit your needs  Pass local as TRUE to make the object orbit around the target's local axis, FALSE for using a global, sim-related axis.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
Thrash Prototype
Registered User
Join date: 24 Aug 2004
Posts: 31
|
09-27-2005 20:30
okay i tried this but it says (12,65) : ERROR : Name not defined within scope
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
09-27-2005 20:36
From: Thrash Prototype okay i tried this but it says (12,65) : ERROR : Name not defined within scope The two llAxisAngle2Rot() calls accidentally have the "X" in "Axis" capitalised. Just a typo, easy fix.
|
Thrash Prototype
Registered User
Join date: 24 Aug 2004
Posts: 31
|
09-27-2005 20:55
okay and what numbers would i change to make it speed up?
it moved once but hasnt since then
edit: i got it to move by pushing it with cursor but it just drifts off in the direction i push it
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
09-27-2005 21:40
From: Thrash Prototype okay and what numbers would i change to make it speed up? it moved once but hasnt since then edit: i got it to move by pushing it with cursor but it just drifts off in the direction i push it If you're using just a plain old prim as your target, change the llSensorRepeat(target, "", ACTIVE|PASSIVE|SCRIPTED, 60.0, PI, 2.0); to read llSensorRepeat(target, "", ACTIVE|PASSIVE, 60.0, PI, 2.0); or for an avatar: llSensorRepeat(target, "", AGENT, 60.0, PI, 2.0);
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
09-27-2005 23:29
Aww, devil's definitely in the details  Why can ACTIVE|PASSIVE detect a simple prim but ACTIVE|PASSIVE|SCRIPTED can't ?
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
09-28-2005 03:01
because | SCRIPTED flags for things that contain a script. It doesn't really OR them together though, in this case it acts like an AND.
|
Thrash Prototype
Registered User
Join date: 24 Aug 2004
Posts: 31
|
09-28-2005 17:36
and what to make it keep going?
it orbits about once but then stops and goes to a certain spot everytime
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
09-28-2005 18:08
From: Jesrad Seraph Aww, devil's definitely in the details  Why can ACTIVE|PASSIVE detect a simple prim but ACTIVE|PASSIVE|SCRIPTED can't ? I'm fair sure it's a bug. I've bugged it, at any rate.
|