+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: My turrets are unstable!

  1. #1
    Wire Noob krail's Avatar
    Join Date
    Jun 2009
    Location
    Sydney, Australia
    Posts
    23

    Default My turrets are unstable!

    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")
    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
    }
    Help me make this better please!
    Last edited by krail; 03-12-2010 at 06:33 PM.

  2. #2
    Wire Sofaking ktccd's Avatar
    Join Date
    Sep 2009
    Posts
    751

    Default Re: My turrets are unstable!

    How is it mounted?
    if it's on a vehicle, wouldn't parenting work? (IDK, maybe parenting stops angular rotation)

  3. #3
    Wire Noob krail's Avatar
    Join Date
    Jun 2009
    Location
    Sydney, Australia
    Posts
    23

    Default Re: My turrets are unstable!

    Quote Originally Posted by ktccd View Post
    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

  4. #4
    billywitchdoctor.com Schilcote's Avatar
    Join Date
    Jan 2009
    Location
    There.
    Posts
    2,006

    Default Re: My turrets are unstable!

    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.


    [19:16:47]Client "rcdraco" spawned in server
    [19:17:10]rcdraco: hamburgertime
    [19:18:04]rcdraco was killed by worldspawn
    [19:21:50]Dropped "rcdraco" from server

  5. #5
    Wire Noob krail's Avatar
    Join Date
    Jun 2009
    Location
    Sydney, Australia
    Posts
    23

    Default Re: My turrets are unstable!

    Quote Originally Posted by Schilcote View Post
    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.
    Yeah I've always tried to stay away from aimpos() and stuff like that because it sucks when your inside a vehicle and can be really twitchy if something gets in front of you :/

  6. #6
    Wire Noob krail's Avatar
    Join Date
    Jun 2009
    Location
    Sydney, Australia
    Posts
    23

    Default Re: My turrets are unstable!

    Sorry if this is getting annoying but I could really use some help with this... anyone?

  7. #7
    Wire Noob Kiefer's Avatar
    Join Date
    Mar 2010
    Posts
    8

    Default Re: My turrets are unstable!

    post a picture how you mount it

  8. #8
    Wire Noob krail's Avatar
    Join Date
    Jun 2009
    Location
    Sydney, Australia
    Posts
    23

    Default Re: My turrets are unstable!

    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)

  9. #9
    Wirererer Elmo the Emo Emperor's Avatar
    Join Date
    Feb 2008
    Location
    Lagville(Austrlia)
    Posts
    278

    Default Re: My turrets are unstable!

    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.

  10. #10
    Wire Sofaking ktccd's Avatar
    Join Date
    Sep 2009
    Posts
    751

    Default Re: My turrets are unstable!

    Also, aimpos does not work in vehicles. However, owner():eye() does. It gives the angle your view has.

+ Reply to Thread
Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots