|
Diego Pannotia
Laronzo Fitzgerald
Join date: 14 Nov 2006
Posts: 37
|
03-18-2007 06:03
The problem with the code below is simple to solve I assume yet bizarre - I can't pinpoint it... The object will rotate to the target on every sensor repeat - yet it will then rotate BACK to its original position!? So every second it turns to the avatar and then turns back! I don't get it. How do I get it to stay put, i.e. maintain the latest sensed rotation? vector AXIS_LEFT = <1,0,0>;
default { state_entry(){ llSensorRepeat("", NULL_KEY, AGENT, 15, PI_BY_TWO, 1); llSetStatus(STATUS_ROTATE_X,FALSE); llSetStatus(STATUS_ROTATE_Y,FALSE); }
sensor(integer num_detected){ vector cur = llGetPos(); vector dec = llDetectedPos(0); vector rot = <dec.x,dec.y,cur.z>; llSetRot(llRotBetween(AXIS_LEFT * llGetRot(), rot - llGetPos())); } }
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
03-18-2007 08:47
I'm not sure what's causing what you're seeing, but I see a few problems. First of all, <1,0,0> is the forward axis, not the left axis. Second of all, what exactly are you trying to accomplish with that rotation math? It looks like it might have been pulled from here: http://www.lslwiki.net/lslwiki/wakka.php?wakka=llLookAtexcept you're missing the key step: multiplying on the left by the current rotation.
|
|
Diego Pannotia
Laronzo Fitzgerald
Join date: 14 Nov 2006
Posts: 37
|
03-18-2007 11:20
perfect thanks, I somehow managed to leave out the llGetRot like you said!
llSetRot(llGetRot() * llRotBetween(AXIS_LEFT * llGetRot(), rot - llGetPos()));
The vectors I used actually work as they should I just forget to relabel AXIS_LEFT +D Thanks very much for the help!
Mark.
|