|
Suzari Wildung
Registered User
Join date: 28 Jun 2006
Posts: 5
|
08-31-2006 12:58
Hellow All. I scripted a working turret on a linked prim, however, my problem is...when the ship rotates to a different angle, from say, 0, 90, 0, to any other rotation along the z axis, it would put the turret out of rotation. To be completely clear: the turret would point to the direction, plus the ships rotation. Since the rotation is usually in an obfuscated rotation var, or even in +PI or -PI, I'm a bit confused. I'll show what code I'm using now, but I'm at a loss how to make due for the ship rotation. Also, since I'm using a rotated prim to aim with, since I use llLookAt in the ship itself to point at something, It's a bit hard to know which rotation I should use. Any idea's on how to get the proper rotation, or how to handle the PI+ and PI- offsets correctly? If you want an example of what I mean, contact me, thank you. vector target = (vector)str; vector xtarget = llGetPos() - target; change = llAtan2(xtarget.y,xtarget.x); vector eul = <-change,PI/2,0>; rotation new = llEuler2Rot(eul); llSetLocalRot(new );
As you can see, I'm using a target on the X,Y plane of SL to calculate what to point at, and then calculate the needed angle to point the turret at. This works fine, until I rotate the ship. :/
|
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
08-31-2006 13:27
try changing that llSetLocalRot to llSetRot, or alternatively llSetLocalRot(new / llGetRootRotation()); Also, use PI_BY_TWO instead of PI/2. one less calculation  .
|
|
Suzari Wildung
Registered User
Join date: 28 Jun 2006
Posts: 5
|
08-31-2006 13:29
I can't use llGetRot, since that doesn't make the prim rotate correctly in relation to the ship. However, your root rotation is an idea! Thanks
|
|
Suzari Wildung
Registered User
Join date: 28 Jun 2006
Posts: 5
|
08-31-2006 13:34
That helped some, it's almost correctly aiming, only off a bit too the left. Will have to experiment with that. I'm thinking using the rotation of only one plane, mostly the x or y might help. thanks!
Edit: It also makes it point somewhat into the ground -laugh-
|
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
08-31-2006 15:45
I'm curious, what is it you're trying to do exactly? give a turret limited freedom of movement? If that's the case I already have a script that does it if you would like the code.
|
|
Suzari Wildung
Registered User
Join date: 28 Jun 2006
Posts: 5
|
08-31-2006 17:15
while I already accomplished this... it worked with your help, I'd surely be interested in that script. Right now the turrets align them interestingly, always pointing straight forward, regardless of height of the target and the alignment of the ship. If you have played most space strategy games, I'm trying to achieve the effect of having turrets trained on the target, like in homeworld. I know it's hard, but still, I'm trying. Next part will probably be the training on the z plane, sine those are still locked.
forgot to mention: I'm using a sensor with an arc of PI/2, so the range of movment is already looked to a hemisphere. I'd gladly show you if I'm online, just drop me a message.
|
|
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
|
09-07-2006 12:41
I definietly need to limit freedom of movmeent with turrets, especially on some projects where the barrel needs to be aimable, but only a little bit. 
|