Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

'Standing up' Rotation that I can't get... Can anyone help?

Never Rust
Registered User
Join date: 27 Apr 2006
Posts: 15
05-22-2006 08:25
I'm working on a humanoid object that is physics-enabled and moves on it's own. When it selects a target, it uses llRotLookAt to look towards the target and then llMoveToTarget to get there.

Often during the course of it's travels, it ends up "fallen over", laying on it's side, or just a little crooked. What I'd like is someway to either keep the object upright at all times (no rotation around x or y I believe), or at least a function that I can call peroidically to tell it to stand back up -- but to also stay facing in the direction it was headed...

Right now I'm using this script when the object reaches it's destination:

rotation MyRot = llGetRot();
vector v = llRot2Euler(MyRot);
rotation rot = llRotBetween(<0.0, 0.0, 0.0>, <v.x, v.y, 0>;);
llRotLookAt(rot, 0.5, 0.5);

This accomplishes the goal of making the object upright, but it always ends up facing the same "zero" direction instead of keeping it's rotation around the z-axis.

I'll gladly pay L$500 to whoever can correct the above code, and another L$500 if someone has a good solution to force the object to maintain an upright position at all times (while still being able to spin around, and not using a "stand" prim).

Thanks!
and if you want to check out my objects for yourself - they're in Terminus, and they're called Plobs.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
05-22-2006 09:07
CODE

rotation my_rot = llGetRot();//change this to anything you want.
vector direction = <1.0,0.0,0.0> * my_rot;
if(direction.x == 0.0 && direction.y == 0.0)//check for gimble lock
direction = -direction * my_rot;//translates the z rot into a position.
rotation rot = llRotBetween(<1.0, 0.0, 0.0>, <direction.x, direction.y, 0.0>);
llRotLookAt(rot, 0.5, 0.5);


Should Work Now
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Jigsaw Partridge
A man of parts
Join date: 3 Apr 2005
Posts: 69
05-22-2006 09:16
I had exactly the same problem with llRotLookAt(), the object always swings round to the same zero rotation about the Z axis. I couldn't find any way round this, I'm afraid.
Newfie Pendragon
Crusty and proud of it
Join date: 19 Dec 2003
Posts: 1,025
05-22-2006 09:42
To maintain vertical orientation I've always used llSetStatus():

CODE
llSetStatus(STATUS_ROTATE_X, FALSE, STATUS_ROTATE_Y, FALSE);



This limits the physics engine from performing any rotations that affect the X or Y axes.


- Newfie
_____________________
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
05-22-2006 09:48
From: Newfie Pendragon
To maintain vertical orientation I've always used llSetStatus():

CODE
llSetStatus(STATUS_ROTATE_X, FALSE, STATUS_ROTATE_Y, FALSE);

- Newfie


Don't you mean...
CODE
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey