does anyone here know a tutorial, mod/mutator, or anything that can help me out on making a moving vehicle?
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.
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
}
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...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.
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