Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotate and object on Z

Jesse Garfield
Registered User
Join date: 13 Jan 2007
Posts: 11
06-26-2007 11:37
I have know idea how to git this to work. This is my first script so I will admit I don't know mutch.

Bassicly I have an object that I move to a location then I need to rotate it a certain degree and wait, then it will move on to another location and I need to rotate it another degree.

My problem is I don't know how to get it to trun say 90 degrees and stop. Eveything I try just keeps spinning the object. Any helpw would be greatly appriciated.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-26-2007 13:32
Sounds like llTargetOmega(), which is setting a spin rate, not a destination for the rotation. So, assuming it's non-physical:
http://lslwiki.net/lslwiki/wakka.php?wakka=llSetRot
Jesse Garfield
Registered User
Join date: 13 Jan 2007
Posts: 11
06-26-2007 13:36
From: Qie Niangao
Sounds like llTargetOmega(), which is setting a spin rate, not a destination for the rotation. So, assuming it's non-physical:
http://lslwiki.net/lslwiki/wakka.php?wakka=llSetRot


Thanks for the info but my object is pysical, that was the only way I could figure out how to move it useing llmovetotarget. But I will look at that site as it is different then where I was looking http://wiki.secondlife.com
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-26-2007 13:46
I don't think you need it physical to use llMoveToTarget (as in the physical checkbox in the prim settings). llSetRot should work. AFAIK, you only need the physical setting if you want to use physics (ie drop it with gravity, or push it with other objects etc).
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-26-2007 14:18
Well... I think it's kinda like this:

____________Physical________Non-Physical
Rotation...........llRotLookAt..........llSetRot
Position............llMoveToTarget....llSetPos
Jesse Garfield
Registered User
Join date: 13 Jan 2007
Posts: 11
06-26-2007 14:28
From: Shadow Subagja
I don't think you need it physical to use llMoveToTarget (as in the physical checkbox in the prim settings). llSetRot should work. AFAIK, you only need the physical setting if you want to use physics (ie drop it with gravity, or push it with other objects etc).


Well I am getting sort of the effect I want. I had to set physics off before doing the turn as you can not do a llMoveToTarget as a non physical. But here is my issue now, it turns way fast. This is supposed to be a ridding horse drawn carrage and going to snap necks, any way to slow the rate down?

Also on the same lines when I do the LLMoveToTarget it starts really fast then slows down as it reaches the target. It would be nice to have a constat speed through the whole movement. I will post the sript as I ahve it now.

Please remember I am new at SL script so my code is probably really messy.

integer Vector_Target;
key kQuery;
integer iLine = 0;
string Location;
integer Wait;
integer Rotation;

Move(vector Location)
{
//llOwnerSay((string) iLine);
Vector_Target = llTarget(Location,.5);
llMoveToTarget(Location, 5);
}
GetConfig()
{
kQuery = llGetNotecardLine("CarrageConfig", iLine);
iLine = 0;
}

default
{
state_entry()
{
llSetStatus(STATUS_PHYSICS, FALSE);
vector eul = <0,0,0>; //45 degrees around the z-axis, in Euler form
eul *= DEG_TO_RAD; //convert to radians
rotation quat = llEuler2Rot(eul); //convert to quaternion
llSetRot(quat); //rotate the object
llSleep(1);
llSetStatus(STATUS_PHYSICS, TRUE);
llSleep(1);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y , FALSE);
llSetStatus(STATUS_ROTATE_Z,FALSE);
llOwnerSay("Reading notecard...";);
kQuery = llGetNotecardLine("CarrageConfig", iLine);
//llOwnerSay("Hello, Avatar!";);
}
dataserver(key query_id, string data)
{
if (query_id == kQuery) {
// this is a line of our notecard
if (data == EOF) {
//llOwnerSay("No more lines in notecard, read " + (string)iLine + " lines.";);
GetConfig();
} else {

// increment line count
//llOwnerSay("Line " + (string)iLine + ": " + data);
list argv = llParseString2List(data, ["'"], [";"]);
Location = llToLower(llList2String(argv, 0));
Wait = llList2Integer(argv, 2);
Rotation = llList2Integer(argv, 4);
llOwnerSay(llToLower(llList2String(argv, 0)));
llOwnerSay(llToLower(llList2String(argv, 2)));
llOwnerSay(llToLower(llList2String(argv, 4)));
Move((vector) Location);
}
}

}

touch(integer total_number)
{

}
at_target(integer Vector_Target, vector targetpos, vector ourpos)
{
llTargetRemove(Vector_Target);
llSetStatus(STATUS_PHYSICS, FALSE);
vector eul = <0,0,Rotation>;
eul *= DEG_TO_RAD; //convert to radians
rotation quat = llEuler2Rot(eul); //convert to quaternion
llSetRot(quat); //rotate the object

if (Wait != 0) {
llSleep(Wait);
}

iLine++;
kQuery = llGetNotecardLine("CarrageConfig", iLine);
llSetStatus(STATUS_PHYSICS, TRUE);
}
}
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-27-2007 09:44
Did you try llRotLook at for your rotations?

llRotLookAt(rotation target, float strength, float damping);

From: someone

For non-physical objects, good strength values are around half the mass of the object and good damping values are less than 1/10th of the strength. For physical objects, this function behaves more like llMoveToTarget, where increasing the strength or tau seems to slow the rotation. Good values for physical objects range between .2 and 1 for both parameters. Asymmetrical shapes require smaller damping.


Sounds like what you're after, it is a rotation with controllable speed.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
06-27-2007 20:29
instead of turning in 90 degrees, turn it in steps...

9 degrees at a time, with a pause in between. Something like

float turn=90;
float delta=9;
float pause=.2;

while( turn > 0) {
<turn delta degrees>
llSleep( pause );
turn -= delta;
}