How is it mounted?
if it's on a vehicle, wouldn't parenting work? (IDK, maybe parenting stops angular rotation)
Ok so in this short period of time I need help once again. Now the problem is I've figured out how to make a decent turret which is pretty stable but the big problem is it becomes horribly unstable and flails wildly when whatever it's mounted on moves. I've made my share of turrets using various methods but I have never been able to make one which can remain accurate when mounted on my spaceships
Here is one of my best turrets: (Main part of the code shamelessly stolen from Fizyk's "Ultimate Quaternion Turret")
Help me make this better please!Code:@name Simple Turret @inputs Base:entity Facer:entity Active @outputs Lock Target:angle AimAng:angle Current:angle Change:angle @persist Var:angle A:angle runOnTick(1) AimVec = owner():eye() Var = Base:eye():toAngle() A = angnorm(ang(AimVec:toAngle():pitch(),AimVec:toAngle():yaw(),-1)) TarQ = quat(A) #Maths :) CurQ = quat(Facer) Q = TarQ/CurQ V = transpose(matrix(Facer))*rotationVector(Q) if(Active){ #Aiming Facer:applyTorque((100*V - 10*Facer:angVelVector())*Facer:inertia()) } if($Var == $A){ #Weld latch (pathetic attempt at stability) Lock = 1 } else{ Lock = 0 }
Last edited by krail; 03-12-2010 at 06:33 PM.
How is it mounted?
if it's on a vehicle, wouldn't parenting work? (IDK, maybe parenting stops angular rotation)
Yes this is the problem with any vehicle. I could parent the base to the vehicle of course but unfortunately it doesn't solve the problem as it is the moving part that flails around
Oh BTW if anyone can show me a method that is stable, it doesnt necessarily have to be based on the code I posted![]()
My turret has the same problem. It spins when it's pointing straight up or down. It's not too much of a problem when it's mounted to a static building, but when you put it on a vehicle it becomes very hard to drive with the thing having a seizure all the time. Making it point where the driver is looking is an improvement, but then you have to, you know, aim it.
Hmm... I have an idea. It's different from my other ones; this one I could actually do, and easily too, but it would be pretty useless. Dang.
Sorry if this is getting annoying but I could really use some help with this... anyone?
Sorry maybe I'm not saying the right thing. My turrets work perfectly under normal circumstances, but when the base prop moves in any direction, the turret is sloppy and flings around randomly. What I need help with is if anyone else has found a solution to this like perhaps some sort of extra force that compensates the movement. (Its not really about where or how I mount it)
Yes it is :3.
If you use a ballsocket say, it should be fine and if it's not you can simply increase the weight to make it stronger.
If however it is applyforcing to above the mount, you might want to have a loot at improving your applyforce formula.
I'm sure there are other methods that i lack the imagination/can't be bothered to think of at the moment, but hopefully you get the idea.
Also, aimpos does not work in vehicles. However, owner():eye() does. It gives the angle your view has.
Bookmarks