Create car physics

Favourite 14 favourites
Tutorial written by CodeMasterMikeOriginally published on 13th, June 2012 - 4 revisions

This tutorial is showing you how to create either a top-down car physics or a side-view car physics with the Car physics behavior.

There is already a nice behavior in Construct, that lets you create a fully controlable car. But that behavior doesnt react or deal with physics, and adding physics to that sprite may cause problems.

This behavior is fully integrated into the physics inside Construct 2, and will react with all physics available, and still have the controls and feel of a realistic car.

Do note that there is a lot of settings, when creating a physics car, and there is no "cookie cutter" settings to create your car. Changing one
setting, ever so slightly, may change the whole car altogether.
So take your time and play around with the settings until you get what you like.

The tutorial is splitted into three parts:
Introduction
Create top-down car physics
Create side-view car physics

These two behaviors are both part of the physics world and share some common settings, but are built differently and have their specific settings that may be little confusing in the beginning.

You can get the behavior files here

If you neeed more information or have questions, go to the forum thread for this behavior

And now onwards to the tutorial!

Comments

0
Piet 2,104 rep

I tried to install the plugin because I want to make a Grand Theft Auto kind a game. It seems not to work for me.
It seems there have been some plugin changes? Because when I do the following, Constructor 2 does not give the error messages but fails to start. When I remove the plugins Constructor does start:
===================================
Install in:
C:\Program Files\Construct 2\exporters\html5\plugins\car
tip: create a directory called "car" there for neatness

Edit edittime.js to replace name of the "GetBehaviorSettings" function with:
"GetPluginSettings"
Also add the following to the file:
// Called by IDE when a new object type is to be created
function CreateIDEObjectType()
{
return new IDEObjectType();
}
===================================
Are there other conditions which a plugin has to meet?

Friday, October 12, 2012 at 2:30:20 PM
0
CodeMasterMike 7,267 rep

@Piet

Why do you wanna change the GetBehaviorSettings functionality name? That makes no sense at all!

You shouldn't change any of the code, specially the code that is created by scirra (GetBehaviorSettings is one of those), since it can break the functionality. As it has for you.

And do note, that my car physics is a behavior, and not a plugin. There is a huge difference and changing a function name inside the code will not change it into a plugin.

If you would want to have a car physics as a plugin, you need to write one from scratch.

Friday, October 12, 2012 at 7:44:29 PM
0
Piet 2,104 rep

@CodeMasterMike
I thought the files where part of a plugin. So I installed it like one. Thank you for pointing out the "big picture" to me.
I'll start looking into writing a plugin.
Thanks!

Saturday, October 13, 2012 at 9:32:17 AM
0
CodeMasterMike 7,267 rep

@Piet

It's maybe little confusing for people who are new with construct, but there are two types of plugins.

There is the plugin, and there is a behavior.
The big difference between these are, except for different installation folders, that a behavior you attach to a object, in this case a car, and a plugin
is like a library which can calculate things for you.

Physics is for instance a behavior, and a text field is a plugin.

If you want to do a GTA-styled game with a physics car. Then you should use a behahvior for the car. Either my Car physics behavior, or Scirras own Car behavior. The difference between these are that scirras Car behavior doesn't have physics.

I hope this sheds little more light on the subject for you :-)

Saturday, October 13, 2012 at 8:42:49 PM
0
vern 2,027 rep

Physics are really cool! But i have a question about side-view car: how to change suspension?

Monday, November 12, 2012 at 9:44:48 PM
0
CodeMasterMike 7,267 rep

@vern

Translate/scale the axles and/or wheels around, that will also change the suspension reaction.

Tuesday, November 13, 2012 at 6:19:23 AM
0
myrtyx 2,083 rep

why when braked the car not completely stopped ? instead slowly moving backwards / reverse

Thursday, January 17, 2013 at 11:39:45 PM
0
myrtyx 2,083 rep

ups sorry, i post on wrong tutorial......

Friday, January 18, 2013 at 4:33:09 AM
0
SALVANDUM ANIMAS 404 rep

I have a question. The program works fine C2 behavior. But when I export through that either the game is started and can be seen only a black screen. Can anyone had this problem?

Friday, January 03, 2014 at 1:43:19 PM
0
garymocock 339 rep
I have a question. The program works fine C2 behavior. But when I export through that either the game is started and can be seen only a black screen. Can anyone had this problem?
quoted from SALVANDUM ANIMAS

I also get this problem. errors with physics instance. cocoonjs will not run the game with the physics... can someone help please?

Sunday, April 06, 2014 at 6:47:18 PM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.