Jump to content

Car Physics


Benton
 Share

Recommended Posts

Hey guys,

 

I am adding my car models into my racing game in place of the scout model that comes with LE. However, my model viewer crashes every time I try to view that scout model so I can't see how it is structured. How each part of the model is named, etc. Could someone help me set up my car model?

 

Thanks,

Benton

 

Edit: The error I get when I change the chassis model to my chassis is:

 

chassis=LoadModel("abstract::muscleblack.gmf")

carobject=objecttable[chassis]

car=carobject.vehicle

 

Error: Attempt to index global 'carobject' a nil value...

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

Error: Attempt to index global 'carobject' a nil value...

 

Try to add a simple lua-script for your model (muscleblack.lua) with code:

require("scripts/class")

local class=CreateClass(...)

 

It will register your model in table "objecttable", if you want so.

Link to comment
Share on other sites

Ok so I need to set up a car from scratch. Can I use some of the scripts that are already written, or do I need to totally write some new code?

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

If I were you I'd learn as much as I can from the existing setup scripts but to be honest, if you really want to understand the mechanics of setting up a car, just experiment as much as you can with all the variables and possibilities until you really understand how each function affects the car physics. Code and test and observe, alter code and retest and observe.

 

That sort of understanding (i.e NO SHORTCUTS) will give you a solid foundation to move forwards on and will inevitably produce a better end result. Yes its going to take some time but it will always be worth it in the long run.

  • Upvote 1

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Yeh you need a solid understanding on the LE vehicle setup. I wouldn't recommend making your own from scratch at least not at this point. Once you have the standard LE vehicle down and you're happy with it, start experimenting with adding artificial external forces.

 

I would recommend:

1. Determine the major 'real forces' that happen on cars in real life, (i.e. drag(most important), momentum, friction etc. etc.)

2. Decide which ones are the most important.

3. Calculate approximations of these forces (or rather make ur code approximately calculate these values).

 

I can't stress enough how you must not try to get exact figures.. You will only get frustrated with that and 99.999% of players won't know the difference between a slight approximation and a perfect calculation of a force.

 

The external forces are rather tough to get right I found, so prepare to play around with them a lot.

 

Oh one more step

4. Determine when the forces are applied and how you want to trigger them in game.

For example I made my car loose traction when a function of its speed and turn angle was greater than a fixed amount.

 

 

Good luck.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

For example I made my car loose traction when a function of its speed and turn angle was greater than a fixed amount.

 

I'd love to know what functions you used to achieve this effect. :)

 

I can work out the speed and turn angles easily enough, but I dont know how to physically change the traction. SetBodyFriction doesn't seem to have any effect for me, is that what you are using?

 

I got some quite interesting effects using SetBodyOmega by forcing oversteer in similar circumstances. It needs a lot of tweaking and I just wonder how others are achieving the effects of low grip and oversteer in their games.

Link to comment
Share on other sites

I'd love to know what functions you used to achieve this effect. smile.png

 

I can work out the speed and turn angles easily enough, but I dont know how to physically change the traction. SetBodyFriction doesn't seem to have any effect for me, is that what you are using?

 

I got some quite interesting effects using SetBodyOmega by forcing oversteer in similar circumstances. It needs a lot of tweaking and I just wonder how others are achieving the effects of low grip and oversteer in their games.

 

It sure is a tricky one and there is no function to simply reduce traction. You have to make it yourself by applying the correct forces to the vehicle to fake momentum and also to stop the tyres turning. Its pretty difficult to get right. But yeh no single function will fix it

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

Yeh you need a solid understanding on the LE vehicle setup. I wouldn't recommend making your own from scratch at least not at this point. Once you have the standard LE vehicle down and you're happy with it, start experimenting with adding artificial external forces.

 

 

The problem I am having is not getting really realistic physics, but getting "the standard LE vehicle" working on my car model. But I don't understand why it is not working.

 

For instance: chassis=LoadModel("abstract::monstertruck.gmf")

carobject=objecttable[chassis]

car=carobject.vehicle

 

error: Attempt to index global carobject a nil value...

 

I can't find any docs for objecttable[chassis]

I just want to get the standard LE vehicle setup working for my model, thats it...

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...