Page 1 of 1

Issues with osNpcSetRot

Posted: Sun Nov 05, 2023 10:34 pm
by Graham Mills
I'm having some difficulty understanding how osNpcSetRot is supposed to work. A web search came up with someone else having similar issues:

https://community.secondlife.com/forums ... te-an-npc/

Any thoughts/code/pointers welcome.

Re: Issues with osNpcSetRot

Posted: Sun Nov 05, 2023 11:09 pm
by Gusher Castaignede
It seems like osNpcSetRot is a function used to set the rotation of an NPC (Non-Player Character).

The function takes two parameters:

The first parameter is the NPC that you want to rotate.
The second parameter is the rotation that you want to apply, which is represented as a quaternion.

..so from the code from that link, they're converting Euler angles to a quaternion with the llEuler2Rot function, and then passing that quaternion to osNpcSetRot.

Euler angles can sometimes lead to a problem known as “gimbal lock,” which might be why you’re seeing unexpected behavior.

One thing you could try and test is to only change the Z component of the rotation, and leave the X and Y components as zero. This would look something like this:

Code: Select all

vector xyz_angles = <0.0, 0.0, 185.0>;
This will rotate your NPC around the Z-axis only, which might be what you’re trying to achieve.
Luck, hope you solve it!

Re: Issues with osNpcSetRot

Posted: Mon Nov 06, 2023 3:16 pm
by Graham Mills
Thanks, Gusher. Will experiment further.