Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Tracking cam and Rotating around one axis.

Thundercracker Bandit
Registered User
Join date: 20 Oct 2007
Posts: 2
03-19-2009 06:49
Hi all, more rotation confusion.

I built a tank and am now trying to get the turret to rotate correctly. My problem is the base of the turret. it needs to track the camera position of the avatar controlling it and then point in that direction. But only on one axis, the z axis. Ive been using the following for the one prim cyclinder barrel.

k = ((<0.00000, 0.70711, 0.00000, 0.70711>*llGetCameraRot())/llGetRootRotation()) * (ZERO_ROTATION/llGetRootRotation());

llSetPrimitiveParams([PRIM_ROTATION,(k)]);

My problem of course is negating the other axis's and still allowing the base of the turret to point in the correct direction.

Ive tried using llSetLocalRot() and zeroing the x and y axis. But of course that only works when the vehical is set at zero rotation.

I read the Lsl wiki and couldnt find a solution to my problem. so could some one help me understand my problem better?
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
03-19-2009 07:49
From: Thundercracker Bandit


Ive tried using llSetLocalRot() and zeroing the x and y axis. But of course that only works when the vehical is set at zero rotation.


I believe if you zero the x and y axis, and then divide by the current rotation (desired_rot/llGetRot() ) it should compensate for the rotations of the base of the tank.
_____________________
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.
Thundercracker Bandit
Registered User
Join date: 20 Oct 2007
Posts: 2
03-19-2009 09:35
From: Senuka Harbinger
I believe if you zero the x and y axis, and then divide by the current rotation (desired_rot/llGetRot() ) it should compensate for the rotations of the base of the tank.


Ahh thanks, i tried so many different combo of different things that didnt work out. Altho i advise people to use llGetRootRotation instead of llGetRot, as the latter caused some strange wobbling.