Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Attachment rotation

Keno Pontoppidan
Registered User
Join date: 20 Oct 2005
Posts: 75
02-26-2008 13:37
How would you get a attachment to rotate to the direction you are looking in mouselook but only on the z axis?
I have been trying to do this for a few days now with no luck, currently i'm using this.

rotation new_rot = llGetCameraRot() * llGetRot();
vector eul = llRot2Euler(new_rot);
vector rot = <0.,0.,eul.z>;
rotation x_45 = llEuler2Rot(rot);
llSetRot(x_45);

This just gives me odd rotations and trying to figure this out is going drive me insane I need help!
RobbyRacoon Olmstead
Red warrior is hungry!
Join date: 20 Sep 2006
Posts: 1,821
02-26-2008 16:25
Are you referring to a HUD attachment, like a radar kind of thing, or an attachment elsewhere on the avatar?

I ask because it's not possible to set the world-relative rotation of an attachment on the avatar. Well, I suppose it might be if you attached it to the hips and never played any animations that changed that, but for all practical purposes it's not feasible.
_____________________
Keno Pontoppidan
Registered User
Join date: 20 Oct 2005
Posts: 75
02-28-2008 09:48
It's attached to the stomach and yes there is a animation the stops all movement, also it's for a tank so you are sitting in a vehicle.

Edit:
My friend helped me out with this, now it dosen't work but its closer than I got

rotation rot = llRotBetween(<0.01, 0.0, 0.0>, <10,0,0>*llGetCameraRot());
vector r2 = llRot2Euler(rot)
r2 = <0.0,0.0, r2.z>;
rot = llEuler2Rot(r2);
llRotLookAt(rot, 0.1, 0.1);

The problem with this is it only works when I face east, if I turn the tank north then look north in mouselook the turret looks west, if I turn the tank west and look west in mouse look the turret points east, Getting the idea? :(