Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Turrets on linked systems

Zindorf Yossarian
Master of Disaster
Join date: 9 Mar 2004
Posts: 160
06-09-2005 15:19
I am curious about making turrets with smooth mouselook-aimed rotation as parts of linked systems. I have seen a working example of this, but have no idea how to work it. The only linked part rotation I know of is llSetLocalRot, and this would not be terribly compatible with mouselook. How might a mouselook aimed linked turret work?
_____________________
Badass Ninja Penguin: Killing stuff it doesn't like since sometime in May 2004.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
06-09-2005 15:49
At a guess?

Step One: Get agent's rotation and/or controls.

Fairly straightforward. You can do this in several ways. Assume we have the agent's mouselook rotation, which is given by the agent's rotation both by attachments and by sensors.

Step Two: Rotate the turret.

Also fairly straightforward. Make your rotation a vector:

CODE
vector zee = llRot2Euler(agents_rot);


And use a rotation function. This is tricky if you want it to work perfectly.

See, the reason we have llSetLocalRot is the rotation functions are buggy in linked sets. Fortunately, this function was released publicly some time ago - before it was an LL function.

Here's what it looks like for llRotLookAt and llSetRot:

CODE
rotation offset = <0,0,0,1>; // Place rotation offset here
rot = llEuler2Rot(<0,0,zee.z>) * offset;

rotation parentRot = llGetRootRotation();
parentRot.s *= -1;
llRotLookAt((rot * parentRot) / ( (ZERO_ROTATION / llGetLocalRot()) * llGetRot()),0.3,0.3);


You should be able to plug that in and make it work.

At a footnote, vehicle code now has mouselook functionality built in, but I don't *think* it would work as a child object. Would it?
_____________________
---