1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

making a car

Discussion in 'Programming' started by JiNX, Dec 4, 2001.

  1. JiNX

    JiNX Omniscient

    Joined:
    Sep 3, 2000
    Messages:
    18
    Likes Received:
    0
    does anyone here know a tutorial, mod/mutator, or anything that can help me out on making a moving vehicle?
     
  2. usaar33

    usaar33 Un1337

    Joined:
    Mar 25, 2000
    Messages:
    808
    Likes Received:
    0
    there is some site with vehicles.

    Any way, the vector calculations and physics knowledge required is probably to advanced for a tuty.
     
  3. mr.s-d

    mr.s-d CHiMERiC Moderator

    Joined:
    Aug 30, 2001
    Messages:
    65
    Likes Received:
    0
  4. Lemoni

    Lemoni The Philosapher

    Joined:
    Feb 17, 2001
    Messages:
    628
    Likes Received:
    0
    do a web search forHALFLIFERALIGH ITS GOT A GOOD FAq for building a car in MS3D
     
  5. JiNX

    JiNX Omniscient

    Joined:
    Sep 3, 2000
    Messages:
    18
    Likes Received:
    0
    thanks guys for all the help, it took awhile for it to download, there seems to be a problem with their servers, but i finally got it to work. its still a little bit hard to make it do what i want, but im starting to get the hang of it, and that tuty on making a car in milkshape helped me out a bunch, thanks guys!
     
  6. Eater1

    Eater1 Coder

    Joined:
    Oct 22, 2000
    Messages:
    176
    Likes Received:
    0
    Well, the hardest part of coding drivable vehicles is not the physics code. Anyone with half a brain can easily whip up a realistic-feeling physics code (even if it's not 100% realistic in reality). The hard part is making the exit/enter code, or, to be more specific, making it net-compatible. There are basically 2 ways that I know of of doing this - the more OO one is to make a sepperate vehicle class that the player literally enters and then all of the player's inputs are fed into that new class. This way is probably harder to make net compatible. The second way is to have the vehicle as a pickup (a very large one, capable of taking damage and all) and when the player picks it up he turns into the vehicle (the mesh changes, the player goes into another state, etc.). This technique won't let you modify your vehicles that much using other objects as you'll have to pretty much stuff everything into your PlayerPawn, but it's MUCH easier to write replication code for. I've tried both ways, and if I were you, I would do the second one if you intend your mod to be multiplayer.

    Eater.
     
  7. JiNX

    JiNX Omniscient

    Joined:
    Sep 3, 2000
    Messages:
    18
    Likes Received:
    0
    Thats exactly what i did, but there are still some problems with it that i cant really figure out, i got the car to do everything and all, but, i just want to add something extra to it, i want the car to smoke, like and overheating engine, i dont want the smoke to be damage triggered though, any help??
     
  8. usaar33

    usaar33 Un1337

    Joined:
    Mar 25, 2000
    Messages:
    808
    Likes Received:
    0
    You think the physics code is easy?
    Write it now (or post your code).

    I'll gladly handle net code. It is nothing compared to the actual movement code.
     
  9. Lemoni

    Lemoni The Philosapher

    Joined:
    Feb 17, 2001
    Messages:
    628
    Likes Received:
    0
    Dud , if u do it can u make some cars/trucks/tanks anyother vechials for ge ut
     
  10. Eater1

    Eater1 Coder

    Joined:
    Oct 22, 2000
    Messages:
    176
    Likes Received:
    0
    I made some tank physics code for the Stratus Edge mod a while ago. It's a bit too long to post here and I never implemented the collision handling part of the code, but the whole acceleration and terrain following worked fine. Trust me, it's not that hard, and once you do it once you can do it again for almost any type of vehicle.

    [EDIT]
    When I said the net code was hard, BTW, I didn't mean impossible. I can write the net code myself too, and I did (for the Titanium Wars and Stratus Edge mods). The mods just never made to a release, but the vehicle code worked fine in both. Vehicle code is very possible to do, but it is sort of pushing the engine to the limit.

    [EDIT]
    I changed the word "bots" in the 3rd sentence to "mods"... damn typos.

    Eater.
     
    Last edited: Dec 9, 2001
  11. usaar33

    usaar33 Un1337

    Joined:
    Mar 25, 2000
    Messages:
    808
    Likes Received:
    0
    ok, Eater, my own car has plenty of physics stuff right now (gravity, engine, friction, air resistance forces), yet it has a major problem changing slopes. I do the following thing on slope changes:

    Code:
    function ProcessCollision(actor Collided,vector CrashAngle){
      local vector oldvelocity;
      oldvelocity=CarVelocity;
      CarVelocity -= 2 * ( CarVelocity dot CrashAngle) * CrashAngle; //vector reflection
      CarVelocity*=EnergyLoss;
      If ((vsize(CarVelocity-oldvelocity)<Gravity&&carvelocity.z>=0)||abs(carvelocity.z)<0.18*gravity){ //not exactly realistic
        carvelocity.z=0;
        SetAcceleration();
        HandleRotation(0);
      }
      Timer(); //update hud info
    }
    
    Crash angle is simply the normal. I also set the pitch and roll to whatever the base normal is. Yet with my code, often the car looses so much velocity when colliding that it cannnot change inclinations when going up hills (even if it is less than 0.01 rad). Any ideas?
     
  12. Eater1

    Eater1 Coder

    Joined:
    Oct 22, 2000
    Messages:
    176
    Likes Received:
    0
    In order for me to get an idea I have to know just how your car works. First of all, what are you trying to do with this:
    If ((vsize(CarVelocity-oldvelocity)<Gravity&&carvelocity.z>=0)||abs(carvelocity.z)<0.18*gravity){ //not exactly realistic
    carvelocity.z=0;
    SetAcceleration();
    HandleRotation(0);
    }
    ?
    What does SetAcceleration and HandleRotation do?
    And what do you mean it doesn't change inclination? If by inclination you mean the car's pitch, that should have nothing to do with velocity. It should either automatically be set to the normal of the terrain the car is on or, if you want to get really realistic, you could use rotationrate and stuff like that to make it slowly assume the pitch of the terrain at a rate that depends on gravity.
    Or do you mean the car's Z coordinate? If that's the case, maybe you should just sacrafice a little realism and have the crash only effect the car's X and Y velocity with the Z velocity dependent entirely on the slope of the ground it's on?
    Anyway, another thing you should keep in mind is that depending on what method you're using to detect collision, that ProcessCollision function of yours may get called when the car is simply driving along on solid ground because it's colliding with the ground it's on.

    Eater.
     
  13. usaar33

    usaar33 Un1337

    Joined:
    Mar 25, 2000
    Messages:
    808
    Likes Received:
    0
    setacceleration() sets the cars acceleration from gravity, air resistance, engines, and friction, as well as the yaw acceleration. It also, if the car is touching the ground will set velocity, relative to rotation, to 0. I've figured out the problem with the inclination changing however... the collision cylinder will never rotate.. the same is true with the extent vector box. Thus when on a steep plane the car will collide with the ground :( I might be able to tweak the traces around however...
     
  14. 2COOL4-U

    2COOL4-U New Member

    Joined:
    Mar 17, 2001
    Messages:
    505
    Likes Received:
    0
    Hey Usaar33 if you finish that code, make an tutorial about it ;). We've planned something like this for DefenceAlliance. And I am only 14 and haven't had any vector stuff on school. So I really need a base in other to make my own drivables :(
     
  15. Eater1

    Eater1 Coder

    Joined:
    Oct 22, 2000
    Messages:
    176
    Likes Received:
    0
    Ah yes... The damn collision cylinder. So see, I was sort of right when I hinted at the fact that your thing might be colliding w/ the ground... By the way, is that car a PlayerPawn? If so, what method are you using to detect collision?

    Eater.
     
  16. JiNX

    JiNX Omniscient

    Joined:
    Sep 3, 2000
    Messages:
    18
    Likes Received:
    0
    I think a tutorial on the basics of making a car would be great, even for me, because i still have some things to figure out.
     
  17. 2COOL4-U

    2COOL4-U New Member

    Joined:
    Mar 17, 2001
    Messages:
    505
    Likes Received:
    0
    Making your car a playerpawn would be easier imho
     
  18. usaar33

    usaar33 Un1337

    Joined:
    Mar 25, 2000
    Messages:
    808
    Likes Received:
    0
    2-cool, I am older than you but not by much. You do need to at least know trigonometry to understand vectors however.

    Well, I finally did get my car to work. I was forced to have manually collision detection by firing off 4 traces (all from the front, on the corners). However, collision detetion fails if a corner of a wall is around the middle of the car. I will probably need to run more traces :(

    Playerpawn is simply not the way to go. Believe me. Right now my car is far more realistic than Airflight UT. (there is not even a max velocity setting... velocity limit only exists due to air resistance). Its realism probably equals Heavy Metal... although with far more simple code (about 1000 lines). The only physics violations are than roll and pitch are not accelerated (just constant velocity) and collisions with the ground generally will not result in a bounce...
     
  19. 2COOL4-U

    2COOL4-U New Member

    Joined:
    Mar 17, 2001
    Messages:
    505
    Likes Received:
    0
    I haven't got that at school yet. I don't know what a Sine, Cosine is. I don't know what a dot product is, yeah I need to learn a lot :)

    [EDIT]I even went to my math teacher and asked if he could explain it to me, guess what he didn't :(
     
  20. usaar33

    usaar33 Un1337

    Joined:
    Mar 25, 2000
    Messages:
    808
    Likes Received:
    0
    Are you presently taking geometry? You will probably learn later in the year.
     

Share This Page