Announcement

Collapse
No announcement yet.

Need help setting up Vehicle Turrets

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need help setting up Vehicle Turrets

    I have a vehicle with multiple turrets. What I would like, is for a turret or it's weaponpawn to set up it's pitch and yaw limitations based on what bone on the vehicle it is attached to. Has anyone dealt with this type of problem? Thanks

    #2
    Pitch and yaw are determined by the wepaon itself, you could just make sepereate subclasses for each bone with their own yaw and pitch....

    Comment


      #3
      Easy solution: make a version that works for all bones, then subclass it once for each bone and set specific pitch/yaw restrictions on them. The subclassed versions don't have to contain any functions or defaultproperties other than the pitch/yaw limits. You'll need to do the same for the turrets, except their subclasses just need the appropriate gun. Don't copy anything into the subclasses if it applies to all of them equally; just keep it stored centrally in the superclass.

      You get a lot of files with very little code this way, but other than that it's reasonably clean.

      Comment


        #4
        I was trying to be clever and avoid that, since it will force me to have (so far) 30 new classes (3 positions, 5 weapons, and the weapon AND the weaponpawn both will have to be subclassed)

        I'm already trying what you suggested, but it seems the game is ignoring the Yaw constraints of the new classes. Pitch works fine though...weird...

        Comment


          #5
          You could try:
          Code:
          Function PreBeginPLay()
          {
              local Name BoneTest;
              local int i;
              local ONSVehicle Vec;
          
              vec = ONSWeaponPawn(Owner).VehicleBase;
          
              for (i=0;i<Vec.WeaponPawns.Length;i++)
                  if (Vec.WeaponPawns[i] == Owner)
                      BoneTest = PassengerWeapons[i].WeaponBone;
          
              if (BoneTest == 'SomeBone')
              ....
          }
          Now that is just a guess and some of the casting might be wrong...

          Comment


            #6
            Cool, I'll give that a try.

            Got the YawConstraints thing figured out, they don't haveany effect if bInstantRotation=True. What a PIA...

            Also, would that code you posted go in the weapon or the weaponpawn? I'm assuming it would go in the weapon class. I'll try later, gotta go see H.H.G.T.T.G. L8r

            Comment


              #7
              Weapon class

              Comment


                #8
                How was hitchhikers?

                Comment


                  #9
                  Originally posted by ghouck
                  Got the YawConstraints thing figured out, they don't haveany effect if bInstantRotation=True. What a PIA...
                  RotationsPerSecond > 2 does just about the same...

                  Judging from this part: "ONSWeaponPawn(Owner)", Hsoolien's code goes in the Weapon.

                  Comment


                    #10
                    Code:
                    BoneTest = PassengerWeapons[i].WeaponBone;
                    Error, Bad or missing expression in '='

                    I'm getting this error for the above line. I Changed it to:

                    Code:
                    BoneTest = Vec.PassengerWeapons[i].WeaponBone;
                    and the compiling error went away, but then I got:

                    (Function AirDef.AirDefGunD.PreBeginPlay:0030) Accessed None 'Vec'

                    Comment


                      #11
                      Ok try:
                      vec=ONSVehicle(Owner.Owner);

                      Comment


                        #12
                        OK, Here's what I have, and it works, although it looks like it shouldn't:

                        Code:
                        local Name BoneTest;
                            local ONSVehicle Vec;
                        
                            vec=ONSVehicle(Owner.Owner);
                            BoneTest = Vec.PassengerWeapons[(Vec.WeaponPawns.Length)-1].WeaponBone;
                        
                            if (BoneTest == 'FGunPoint')
                        .......
                        The line: Vec.WeaponPawns.Length is the PassengerWeapons(variable)+1 of where that weaponpawn is attached. PassengerWeapons(0) will have a Vec.WeaponPawns.Length of 1, PassengerWeapons(1) will have a Vec.WeaponPawns.Length of 2 and so on and so on. I found this out when i added log(Vec.WeaponPawns.Length) BEFORE the for-next loop. This caused log entries to be a 1, 2, and a 3. This seems odd since one would believe that length would be the number of weapons in that array (it seems your code was expecting that also), but it doesn't. so far, it seems to work flawlessly, but I'll test it more. Thanks to everyone that helped here, it is greatly appreciated.

                        p.s. Went and saw HHGTTG. It was a fairly entertaining movie, but they deviated from the books quite a bit. If you're a HHGTTG purist, you might want to pass it up, but otherwise, it was OK. It was a lot like I expected, VERY VERY condensed.L8r

                        Comment


                          #13
                          So my for loop does not work your saying?

                          Since the weapon could have been spawned by any Weapon Pawn attached to the vec, the first step was finding out what pawn number is my owner in the attached pawnarray (if (Vec.WeaponPawns[i] == Owner)), then check that number in the PassengerWeapons for the corresponding bone...


                          Length returns the number of elements in an array, but the elements are counted starting at 0, so yes if you set an array like so:
                          BlahArray[0] = Element;


                          Then
                          BlahArray.Length == 1;

                          Comment


                            #14
                            Basically, "Vec.WeaponPawns.Length" in this function, is NOT the length of the weaponpawns array in vec, but rather the position in that array of the class that this variable is accessed from. If there are 3 weaponpawns in Vec, and the weapon is in the first (passengerweaponpawn(0)), vec.weaponpawns.length in that class will be 1. Doesn't make much sense to me, but it works.

                            I put "log(vec.weaponspawn.length); inside the for-next loop of your code. The vehicle has 3 passengerweapons, and all 3 are the same, and all call this code, but my log shows:
                            scriptlog: 1
                            scriptlog: 2
                            scriptlog: 3



                            If I change the second weapon to a weapon without this code and leave it as the first and third weapons, I get:

                            scriptlog: 1
                            scriptlog: 3



                            Weird, eh?

                            Edit:
                            I put "log(vec.weaponspawn.length); inside the for-next loop of your code.
                            That should read "Before the For-next loop", not inside

                            Comment


                              #15
                              That's not odd at all, each time that funciotn is called is when the weapon is spawned and added to the vec weaponpawn array, so what's happened is that every time that function is called the array of weaponpawns is longer, the reaosn channging the second weapon changes the out put is that the second weapon still makes the array larger, but does not log because it does not have the above funciton.


                              And I guess since the function is called before any other wepaon pwns are added, then WeaponPawns.Length-1 is as good a method as youc an hope for to identify ther right Bone


                              And the weapon array lengfth and postion makes perfect sense if you think about it...

                              When the weapon pawn is spawned, it addes one element to the array, (but is in element 0) however there is still 1 element, so that si the resulting length

                              Comment

                              Working...
                              X