Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Turret Troubles.

Kayin Zugzwang
A Superior Grouch
Join date: 7 Jun 2004
Posts: 269
08-03-2004 22:36
I'm working on a rotating turret vehicle but I encountered a massive issue(or so it would seem). Now, I had a few of these before in this project, so I'm sure, as always, theres a solution.

This turret is shaped like a tank turret, as in.. theres a base with a tube coming out of it. Now the turret cannot pitch(aim up or down, incase I misused "pitch";) or roll, just turn. So the issue is getting the turret to aim up and down. The turret is only one prim, so I can rotate it with llsetrot, but it doesn't line up at all, since it pivots at the middle and the the end.

Now, I don't necessarily need a script here(though I would be forever gracious to someone who could give one), but I need a way -- and idea -- on how I could make the turret aim up and down without moving the vehicle its self.

Idea? Suggestions? Scripts?
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
08-03-2004 22:54
your problem has the same solution as here:
/54/b7/19174/1.html
_____________________
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
Kayin Zugzwang
A Superior Grouch
Join date: 7 Jun 2004
Posts: 269
08-03-2004 23:02
Clever solution, the only problem is I'm using a cylinder. Granted I could change this.... but then theres the issue of rounds leaving the barrel. Granted I could have them spawn right at the tip. I think the barrel is bigger too(then 5 meters)

It'll certainly work if I can come up with no other solution.

Perhaps using the same idea I could use a half alpha texture. Granted it would have a moving collision box, but it might be worth the sacrifice.

Thanks for giving me an idea. Anyone else have one that would include less changes?
Kayin Zugzwang
A Superior Grouch
Join date: 7 Jun 2004
Posts: 269
08-04-2004 00:22
I did it and now I'm faced with a new problem. Getting it to rotate the right way. It pivots perfectly and if its rotated to all zeros it works perfectly.... But if its at any other facing or angles then the turret will bend at a weird angle. Any way to fix this?

Heres the test code i'm using to rotate it.

CODE

string temp;
string temp2;
integer angle = 0;
integer face = 0;
float power = 1;
vector rota;

default
{
state_entry()
{

llListen(17,"",llGetOwner(),"");
}


listen(integer channel, string name, key id, string message)
{
{
if (llGetSubString(message,0,5) == "angle ")
{
angle = (integer)llGetSubString(message,6,llStringLength(message) - 1);
rotation x_45 = llEuler2Rot( <0, angle * DEG_TO_RAD
/, 0> );

rotation new_rot = llGetRot() * x_45; // compute global rotation
llSetRot( new_rot ); // orient the object accordingly
}

if (llGetSubString(message,0,4) == "face ")
{
face = (integer)llGetSubString(message,5,llStringLength(message) - 1);
temp = "Face set to " + (string)face;
llWhisper( 0, temp);
vector eul = <0, 0, face>; //45 degrees around the z-axis, in Euler form
eul *= DEG_TO_RAD; //convert to radians
rotation quat = llEuler2Rot( eul ); //convert to quaternion
llSetRot( quat ); //rotate the object
}



}
}