Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need to make that one prim faces to another and move there

Animations Pfeffer
Registered User
Join date: 29 Jul 2007
Posts: 99
08-16-2007 19:28
Hi

All i need is that too prims comunicate each other.
One told the other its own x,y,z and then, the second prim faces it and moves there.

But, im failing at llRotLookA(

How to get the rot if i have the x,y,z of the target prim?

I was doing this, but i realise that i was messing up things:

listen( integer channel, string name, key id, string message )
{
list tokens = llParseString2List(message,[","],[]);
MyPos.x = llList2Float(tokens,0);
MyPos.y = llList2Float(tokens,1);
MyPos.z = llList2Float(tokens,2);
vector pos = <MyPos.x,MyPos.y,MyPos.z>;
vector eul = <MyPos.x,MyPos.y,MyPos.z>;
eul *= DEG_TO_RAD; //convert to radians
rotation quat = llEuler2Rot(eul); //convert to quaternion
llMoveToTarget(pos+offset*quat,.3);
llRotLookAt(quat, .1 , 1);
}

Thanks in advance for your help :)
Animations Pfeffer
Registered User
Join date: 29 Jul 2007
Posts: 99
08-16-2007 21:22
Tried this one without succes

integer Channel = 12;
vector MyPos;
vector offset =<-1,0,1>;

default
{
state_entry()
{
llListen( Channel, "", NULL_KEY, "" );
}

listen( integer channel, string name, key id, string message )
{
llOwnerSay("Recibi: " + message);
list tokens = llParseString2List(message,[","],[]);
MyPos.x = llList2Float(tokens,0);
MyPos.y = llList2Float(tokens,1);
MyPos.z = llList2Float(tokens,2);
vector pos = llVecNorm(<MyPos.x,MyPos.y,MyPos.z>;);
rotation rot = llRotBetween(llVecNorm(llGetPos()),pos);
//llMoveToTarget(pos,3);
llRotLookAt(rot, .5 , .5);
}
}

This works IF its physical, but i dont want it to be physical:

listen( integer channel, string name, key id, string message )
{
llOwnerSay("Recibi: " + message);
list tokens = llParseString2List(message,[","],[]);
llSay(0,llList2String(tokens,0));
llSay(0,llList2String(tokens,1));
llSay(0,llList2String(tokens,2));
MyPos.x = llList2Float(tokens,0);
MyPos.y = llList2Float(tokens,1);
MyPos.z = llList2Float(tokens,2);
vector pos = llVecNorm(<MyPos.x,MyPos.y,MyPos.z>;);
vector pos1 = <MyPos.x,MyPos.y,MyPos.z>;
//llMoveToTarget(pos+offset*quat,.3);
rotation rot = llRotBetween(llVecNorm(llGetPos()),pos);
llSay(0,(string)rot);
//llMoveToTarget(<MyPos.x,MyPos.y,MyPos.z>,1);
//llRotLookAt(rot, .5 , .5);
llMoveToTarget(pos1,1.5);
llRotLookAt(rot, .5 , .5);
//llResetScript();
}
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
08-17-2007 00:27
From: Animations Pfeffer

rotation rot = llRotBetween(llVecNorm(llGetPos()),pos);



that is where it's going awry. Try this:

rotation rot=llRotBetween(<1,0,0>,llVecNorm(pos - llGetPos());


that should allow you to rotate the forward x axis of your object to point at pos. if you wish to have, say, the top Z axis, then use <0,0,1>
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Animations Pfeffer
Registered User
Join date: 29 Jul 2007
Posts: 99
08-17-2007 11:30
From: Senuka Harbinger
that is where it's going awry. Try this:

rotation rot=llRotBetween(<1,0,0>,llVecNorm(pos - llGetPos());


that should allow you to rotate the forward x axis of your object to point at pos. if you wish to have, say, the top Z axis, then use <0,0,1>



Yes, you are right!!

Thanks :)