making a car

  • 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.

JiNX

Omniscient
Sep 3, 2000
18
0
0
38
Visit site
does anyone here know a tutorial, mod/mutator, or anything that can help me out on making a moving vehicle?
 

JiNX

Omniscient
Sep 3, 2000
18
0
0
38
Visit site
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!
 
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.
 

JiNX

Omniscient
Sep 3, 2000
18
0
0
38
Visit site
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??
 

usaar33

Un1337
Mar 25, 2000
808
0
0
Unknown
www.UsAaR33.com
Originally posted by Eater1
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.

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.
 
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:

usaar33

Un1337
Mar 25, 2000
808
0
0
Unknown
www.UsAaR33.com
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?
 
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.
 

usaar33

Un1337
Mar 25, 2000
808
0
0
Unknown
www.UsAaR33.com
Originally posted by Eater1
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.
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...
 

2COOL4-U

New Member
Mar 17, 2001
505
0
0
37
dot NL
2cool.free.fr
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 :(
 

JiNX

Omniscient
Sep 3, 2000
18
0
0
38
Visit site
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.
 

usaar33

Un1337
Mar 25, 2000
808
0
0
Unknown
www.UsAaR33.com
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...
 

2COOL4-U

New Member
Mar 17, 2001
505
0
0
37
dot NL
2cool.free.fr
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 :(
 

usaar33

Un1337
Mar 25, 2000
808
0
0
Unknown
www.UsAaR33.com
Originally posted by 2COOL4-U
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 :(

Are you presently taking geometry? You will probably learn later in the year.