Announcement

Collapse
No announcement yet.

Looking for a video tutorial on vehicles

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

    Originally posted by Mad Maxx
    However the wheels rotate in the forward direction when I move backward. I am not sure what is wrong there?
    Hey, Maxx!

    This part of script:
    Code:
       if (Velocity Dot Vector(Rotation) > 0) MoveDirection = +1;
       else MoveDirection = 1;
    ...has two outcomes - it compares direction of your vehicle's speed to the direction of vehicle itself (and it should return two opposite coeffs based on whether you go forward or backward). In your current form it always returns positive 1 (MoveDirection = +1 and MoveDirection = 1 are the same; so wheels 'think' they're always turning same direction).

    In order to make them work as intended you have to 'mirror' outcomes. Two variants are possible (notice sign changes before 1s)

    Code:
       if (Velocity Dot Vector(Rotation) > 0) MoveDirection = +1;
       else MoveDirection = -1;
    or

    Code:
       if (Velocity Dot Vector(Rotation) > 0) MoveDirection = -1;
       else MoveDirection = 1;
    ...but only one of them actually coincides with proper movement direction.
    - got sig? -

    Comment


      Exo, thanks for adding the explanatory post The bone alignment in my own tank model is not World-aligned so I had to invert the direction for my tank instance.

      Maxx, I'll see if I can add some code, but it will basically be doing something similar to the tread panner code does using the LinSpeed value that is calculated from the angular velocity around the Z (up) axis.

      [EDIT] Ok, here is a modified version of the 'TurnMyWheels' function that will also add in rotation to the wheels when turning in place, you will probably need to swap the signs for the right and left side that I highlighted below in green and orange. The new additions are highlighted in blue.

      Code:
      
      simulated function TurnMyWheels(float DeltaTime) // made this function simulated so that client's version/copy of the tank wheels will also turn.
      {
          local float DeltaPitchBigWheel, DeltaPitchSmallWheel;
          local float TankSpeed, MoveDirection, DeltaRot;
          local KRigidBodyState BodyState;
      
          KGetRigidBodyState(BodyState);
          TankSpeed = VSize(Velocity); 
          DeltaRot = DeltaTime * 65536; 
          DeltaPitchBigWheel = (TankSpeed / BIGWheelC) * DeltaRot;
          DeltaPitchSmallWheel = (TankSpeed / SMALLWheelC) * DeltaRot;
      
         if (Velocity Dot Vector(Rotation) > 0) MoveDirection = +1;
         else MoveDirection = -1;
      
         WheelRotR.pitch += (DeltaPitchBigWheel * MoveDirection);
         WheelRotRsmall.pitch += (DeltaPitchSmallWheel* MoveDirection);
      
         WheelRotL.pitch += (DeltaPitchBigWheel * MoveDirection );
         WheelRotLsmall.pitch += (DeltaPitchSmallWheel* MoveDirection);
      
           // only add the rotation when the tank is going really slowly or stopped
          if(TankSpeed < 200)
          {
               // The only reason that we don't have to use 'DeltaTime' in these calculations for "time scaling" the movement
               // is because the Angular Velocity around the Z-axis, AngVel.Z below, is already scaled by time 
               // (delta rotation /time since last frame).  NOTE, you shou;d adjust the 800 and 1200 numbers until 
               // the rotation looks good in game.
               WheelRotR.pitch += 800 * BodyState.AngVel.Z;
               WheelRotRsmall.pitch += 1200 * BodyState.AngVel.Z;
               WheelRotL.pitch -= 800 * BodyState.AngVel.Z;
               WheelRotLsmall.pitch -= 1200 * BodyState.AngVel.Z; // the small wheels turn faster for the same 
                                                                                      // tread change, so rotate them more
          }
      
          SetBoneRotation('WheelBigR_1', WheelRotR, , 1.0);
          SetBoneRotation('WheelBigR_2', WheelRotR, , 1.0);
          SetBoneRotation('WheelBigR_3', WheelRotR, , 1.0);
          SetBoneRotation('WheelBigR_4', WheelRotR, , 1.0);
          SetBoneRotation('WheelBigR_5', WheelRotR, , 1.0);
          SetBoneRotation('WheelBigR_6', WheelRotR, , 1.0);
          SetBoneRotation('WheelBigR_7', WheelRotR, , 1.0);
          SetBoneRotation('WheelBigR_8', WheelRotR, , 1.0);
          SetBoneRotation('WheelSmallR_1', WheelRotRsmall, , 1.0);
          SetBoneRotation('WheelSmallR_2', WheelRotRsmall, , 1.0);
          SetBoneRotation('WheelSmallR_3', WheelRotRsmall, , 1.0);
      
          SetBoneRotation('WheelBigL_1', WheelRotL, , 1.0);
          SetBoneRotation('WheelBigL_2', WheelRotL, , 1.0);
          SetBoneRotation('WheelBigL_3', WheelRotL, , 1.0);
          SetBoneRotation('WheelBigL_4', WheelRotL, , 1.0);
          SetBoneRotation('WheelBigL_5', WheelRotL, , 1.0);
          SetBoneRotation('WheelBigL_6', WheelRotL, , 1.0);
          SetBoneRotation('WheelBigL_7', WheelRotL, , 1.0);
          SetBoneRotation('WheelBigL_8', WheelRotL, , 1.0);
          SetBoneRotation('WheelSmallL_1', WheelRotLsmall, , 1.0);
          SetBoneRotation('WheelSmallL_2', WheelRotLsmall, , 1.0);
          SetBoneRotation('WheelSmallL_3', WheelRotLsmall, , 1.0);
      }
      Hopefully that works!
      Last edited by meowcatbuf; 03-17-2017, 12:32 AM.

      Comment


        Hi Maxx,
        For the hovering off the ground issue, try lowering the "HoverCheckDist" variable from 65.0 to something like 60.0 or 55.0 and see if that looks better.

        I'll edit this post for the tread panner stuff in a little while.

        [EDIT] For the Panners, you need to change the lines that read:
        LeftTreadPanner.PanRate = +1 * LeftTreadPanner.PanRate;

        and

        RightTreadPanner.PanRate = +1 * RightTreadPanner.PanRate;

        to....

        LeftTreadPanner.PanRate = -1 * LeftTreadPanner.PanRate;

        and

        RightTreadPanner.PanRate = -1 * RightTreadPanner.PanRate;

        If that ends up making the tracks go in the wrong direction when going both forward an backward, all you need to do is change the "TreadVelocityScale" from 450.0 to -450.0 in the default properties. (you could also change the "Velocity dot vector(rotation)..." comparison check code, but editing the default prop accomplishes the same thing).
        Last edited by meowcatbuf; 03-17-2017, 08:42 PM.

        Comment


          I got my built-from-scratch version of the Falcon almost complete and in game, just need to make the team color skins now.



          In game it ends up serving the same purpose as my Blackhawk helicopter vehicle: as it has the Pilot, 2 side gunners, + passengers, but obviously looks more sci-fi and is a bit more compact (also does not feature any air-to-air missiles). It has been fun to test this with bots acting as my flag capturing raid team in VCTF We swoop in, disembark the Falcon, grab the flag, usually one or two bots die (bless their soul-less AI efforts), then the remaining team hops back in the copter and makes a bee-line back to base while sometimes fending off the enemy's Falcon and weaving between enemy turret fire.
          Attached Files

          Comment


            Originally posted by meowcatbuf View Post

            We swoop in, disembark the Falcon, grab the flag, usually one or two bots die (bless their soul-less AI efforts), then the remaining team hops back in the copter and makes a bee-line back to base while sometimes fending off the enemy's Falcon and weaving between enemy turret fire.
            This sounds like lot of fun! True spirit of vehicular games.

            Do you use regular helo's sound for your Falcon? (or maybe some sci-fi stuff too?)
            - got sig? -

            Comment


              @ exo: I think I have a helo sound that I grabbed off the web (FindSound.org maybe?), but I've had quite a bit of trouble getting the helo sounds to play loud enough. I have always had a hard time getting sounds that I edit in either WavePad or Audacity to import and play at a commensurate volume since you can only amplify the sound so much before it starts clipping and distorting really badly, and the PlaySound volume parameters pretty much max out at something like 1.0 right (while taking the TransientSoundVolume and SoundVolume property into account)? You got any recommendations or hints? (my MH53 ginormous helicopter sounds so quiet in game that it is seems silly) Maybe there is some missing "Volume" property embedded in .wav files that I am missing to begin with...

              @ Maxx: So first a couple of recommendations: Always name files/assets (like animations, meshes, staticmeshes, textures, and package names) differently to prevent the engine from confusing them. In your screenshot it looked like the mesh and animation file shared the same name, BF2142, that could cause problems. Maybe name one 'BF2142_Mech_mesh' and the other 'BF2142_Mech_anim'.

              When you say it won't let you put collision boxes on the mesh, do you mean that the collision boxes don't show up at all when you try to set them, or does the collision box array not even allow you to add an item to it?
              Last edited by meowcatbuf; 03-20-2017, 08:46 PM.

              Comment


                Originally posted by meowcatbuf View Post
                @ exo: I think I have a helo sound that I grabbed off the web (FindSound.org maybe?), but I've had quite a bit of trouble getting the helo sounds to play loud enough. I have always had a hard time getting sounds that I edit in either WavePad or Audacity to import and play at a commensurate volume since you can only amplify the sound so much before it starts clipping and distorting really badly, and the PlaySound volume parameters pretty much max out at something like 1.0 right (while taking the TransientSoundVolume and SoundVolume property into account)? You got any recommendations or hints? (my MH53 ginormous helicopter sounds so quiet in game that it is seems silly) Maybe there is some missing "Volume" property embedded in .wav files that I am missing to begin with...
                Yup, sound propagation in UT2004 was one of my few issues about engine (especially compared to HL1/HL2). Every time I needed sound to be loud and clear I just used rather big values for SoundVolume and SoundRadius (with latter having much greater impact). And for some special cases I even used separate actor/attach that is "responsible" for noise creation (like engine humming etc) - which allowed for finer control (for instance, vehicle could produce hit- and other sounds with its own sound settings/channels, while having uninterrupted but controlled engine noise with different settings at the same time - especially when AmbientSound is already taken by some another functionality). IIRC, in rare-rare and extreme cases I could even use multiple attachments, so their sounds attenuate accordingly.
                - got sig? -

                Comment


                  Hi Maxx,
                  Yeah I got the H3 Elephant/Behemoth/Leviathan properly carrying vehicles now (you have to drive them into the bay, exit them and then the Elephant driver can altfire which "locks them down" until someone re-enters them). I may get around to cleaning up the vehicle at some point but there are very few maps that it can be used in so my motivation to do so is kind of low. I actually think I might enjoy making a vehicle like the Mammoth more, but obviously the whole map-size issue is still a problem and I only have a couple of ideas of my own VCTF maps to make so we'll see if I ever get around to it.

                  For your Mech vehicle I think the problem is that you only have one Thruster listed in your default properties it appears to be way out in front from the mech on the X-axis (use the console command "kdraw contacts" to see a red line where the thruster is contacting the ground). You might want to change it to something like
                  ThrusterOffsets(0)=(X=0.0,Z=10.00)

                  to start with. The "Camera Underground" thing is probably the result of the vehicle sitting on the ground (I get the same thing in one of my copters when I get too close to the ground.


                  @ exo: That is a good suggestion regarding using another actor to handle those types of sounds for the vehicle. The only question/issue I run into with added dummy actors is whether the sound notifications replicate properly.
                  Last edited by meowcatbuf; 03-21-2017, 08:48 PM.

                  Comment


                    Hey Maxx!

                    What regards your mesh being unable to hold above ground, I've just noticed its script is based on Manta, but it seems you've removed 2 hover thrusters out of 3. So Manta was supported with 3 points (like a tripod - i.e. minimum points to get a statically stable object), but your mech now have to rely on only one point (which is not very well because this makes him unstable, but in the first place, sole thruster is just not strong enough to handle vehicle's weight).

                    By moving collision to ground level you're effectively make your vehicle lying on its belly (i.e. it actually scrapping floor while moving). I'd suggest to revert to original 3 thrusters (and then we could see if this would make any differences):

                    Code:
                         ThrusterOffsets(0)=(X=95.000000,Z=10.000000)
                         ThrusterOffsets(1)=(X=-10.000000,Y=80.000000,Z=10.000000)
                         ThrusterOffsets(2)=(X=-10.000000,Y=-80.000000,Z=10.000000)
                    - got sig? -

                    Comment


                      Hey Maxx,

                      to remove the turret, try this instead:
                      Code:
                         DriverWeapons(0)=(None)
                      (commenting out DriverWeapons didn't worked because of inheritance - what we were talking about a few posts ago; by commenting mech's DriverWeapons(0) you basically just telling the game to use mech's parent's DriverWeapons(0) - which is regular tank turret)

                      And I'm just thinking maybe this mech actually should have a "turret" - I mean whole top half should follow driver's aim anyway, right?
                      - got sig? -

                      Comment


                        Hey Maxx, the reason that the Thrusters were not working is that the 'Z' offset should probably be something more like 200 rather than 10 (or really at whatever the distance is measured up from the feet to the center of the collision box at the 'pelvis' level of the mech model). The reason we (or at least I) missed this is that most skeletal model are centered around the origin so I assumed that the thrusters would start at "waist level" on the model, but since the model origin was at the feet, by the time the collision box stopped the model, the thrusters were already below the terrain/ground level and basically tracing down into nothingness.

                        As for that console command, you bring up the console while playing the game (usually with the tilde ~ key), and then type "kdraw contacts" (without the quotes).

                        Comment


                          Originally posted by Mad Maxx
                          You make a good point there, I will cut the mech in half in 3dsmax. BTW, I need to delete the "Fire" and "Idle" animations in 3dsmax.
                          The problem is they are on frames 0-7 and 7-15. Is there a way move frames around (if you know what I mean) or should I just leave them in?
                          Actually you could do either way

                          - anim keys are move-able in 3ds max (you could shift-select multiple of them and then just drag to new position)
                          - ...but actually I don't see the need to doing so. Just digest only needed anims into your PSA.
                          - got sig? -

                          Comment


                            The only reason I was thinking that the hovercraft code might be the way to go was that I think you can make it work with only one thruster, and with the upright stiffness or tensor matrix set up properly I think it could be "stable" enough. The Hover Tank code, if you use more than one thruster, will tilt the mech sideways on slopes; you could probably get around this by manually adjusting the thrust distance check in realtime by using some slope checking uscript code and accessing the vehicle's KarmaParams' Repulsors array (see ONSTreadCraft's event 'SVehicleUpdateParams()' for an example of how to access this variable) but that gets a bit more complicated.

                            Comment


                              Hi Maxx,
                              Collision boxes on the feet would work OK, but if you did not also have them on the legs you could theoretically walk/move "through" horizontal bars/level geometry because the foot collision would go below, and the body collision over the top. I think a possibly better option would be to make a larger "leg" collision box that blocked karma only for each leg, that was based off of the root bone; that way the legs themselves could be assigned their own boxes that followed the animations but the non-animated karma colliding boxes would still keep the mech-to-world geometry collision looking OK. The leg karma collision boxes should extend from the mech's waist level down to maybe the feet or slightly above.

                              Comment


                                Not quite what I meant, but close.

                                Create the boxes you are showing in the picture you posted, but make those collide only with bBlockZeroExtent and bBlockNonZeroExtent traces, leave bBlockKarma for them false. These boxes will be for player collision.

                                Create two more boxes (one for each leg) that ONLY bBlockKarma (=1, bBlockZeroExtent and bBlockNonZeroExtent=0) that are based off of either the 'root' or 'Hips' bone, and make the box large enough to mostly encompass the legs. These boxes will be for collision with world geometry (the level) and other vehicles.

                                See the red box below I added to your posted figure for an example.




                                Also, as a side note, would you mind posting a couple of screenshots of the interior of the converted Mammoth vehicle (wire frame or smooth shaded would work too)? I'm trying to get some ideas of what to put on the inside of a similar vehicle (one that will be easier to make collision boxes for) that I'd like to make and I was trying to get an idea for the scale of the vehicle and what the interior looked like. Thanks!
                                Attached Files
                                Last edited by meowcatbuf; 03-25-2017, 02:50 PM.

                                Comment

                                Working...
                                X