[Behavior] Car physics

0 favourites
From the Asset Store
Race with others on this challenging road and become the best!
  • A few more things/notes I have noticed since experimenting pretty heavily. There may be ways around these "missing" features, but I'm not seeing them. Perhaps you can clear some other things up too :)

    1 - Since braking/reverse is a single action, and there is no negative for "speed" of the object (IE, a reverse speed) it's difficult to set maximum speed for reverse while still allowing braking above the desired maximum reverse speed. Any chance of either separating the brake/reverse actions, or applying a negative to a reverse speed?

    2 - Moving the car "body" or "chassis" as I have called it, on start of layout, causes some crazy effects. If I want the car to start on a random position and angle on the layout, what's the best way to do this? I have tried setting the X,Y, and Angle of the "chassis" and all of the "wheels" on start. The front wheels seem to be fine, but the rear wheels are usually not present, and come 'flying' in to the car from some random position in the layout.

    This also applies some pretty heavy physics forces to the car, sending it driving/spinning away. Setting the chassis to 'immovable' temporarily fixes this problem, but stops the vehicle from appearing at a random X,Y (though the angle is still random).

    I have tried ordering when the "carphysics created" from your behaviour takes effect, but it still causes the problem. Any hints/tips?

    3 - What does the "topdown car settings - specific settings for topdown car behaviour" option do? I can figure out the rest of the behaviour options, more or less, but that one has me stumped.

    4 - Is there a way to 'set' the speed of the vehicle directly? I know you can do a speed comparison (for making shifting gears, etc) but I can't seem to 'set' the speed without applying forces via physics. When the car hits an object, it seems to maintain it's forward momentum, even when it's hard up against a wall or other obstacle. It then takes a while (depending how fast you're driving) until it will reverse, (or go forwards if you've hit the obstacle in reverse). I'd like to be able to do something like "car hits obstacle -> set speed to current.speed - X" in order to quickly scrub off a percentage of the speed.

    Again, awesome addition. Hopefully I can figure out some of these minor issues :)

    ~Sol

  • SoldjahBoy Thanks for the input! Some nice ideas you have written down.

    Although I have to say, that I haven't updated this behaviour for around a year now. The company I worked for where I started to developed this behaviour doesn't exist anymore, and Im working at another company, where we don't use Construct.

    I do have a Construct licence myself and my plan was to work with Construct on my spare time, but work and family is taking all my time, so I haven't been able to work with Construct at all for the last year, and I don't know when I can sit down and update my plugin/behaviour projects I enjoy working on.

    Now to your comments!

    • With the crashing on export, I cant say why. I was working when I did the behaviour, although that was around the r100 update, so things have changed and therefor it probably doesn't work as it should. The behaviour relies heavily on the internal physics engine in Construct, so if there was a internal change, the risk is it affects this behaviour. Try to export without using "minify script", and see if that helps.
    • With getting a more feeling of "asphalt" then I cant straight out say what you need to change, since changing one parameter can change the feeling of the car, so the sollution lies there somewhere, just takes amount of time to get it right. But I would think it lies in the wheels and how their settings are set.

    I used to work with Virtools and their car physics, which had loads and loads of settings to play around with. And it could take very long time with fine tuning to get the car behaviour you wanted.

    In my todo list, there is more settings I would like to test and develop to change the behaviour of the car physics.

    2. Stuff like that is what I want to develop for the behaviour in the future, but as I stated, I don't know when that will be.

    3. I can't remember really what caused this. But normally you need to place the car objects before you add the car physics. moving the car after the physics is set, then issues like this can appear. Don't know if that is the cause of your issue though.

    4. This setting doesnt do anything. I put it there to make it easier to seperate the setting parameters. There is probably a better way to do it now :-)

    5. Maybe its possible to make some function for that. But generally you would need to use some kind of force since that is how you make a pyhsics object to move, to make the movement and physics behaviour realistic.

    Im glad that you enjoy using this behaviour, and I hope I get some time soon to update it, and add my list of features and fixes that I have in my head.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey Mike,

    Thanks for the answers :)

    I tried exporting without having "minify script" and it's now working, thank you :D

    To the rest of my questions, I will just figure out creative work-arounds for those issues for the time being. ;)

    I hope you find the time to get back in to doing Construct 2 plugin/behaviour development. Stuff like this behavior is really nice for code-lamens like me.

    Thanks again, and peace ;)

    ~Sol

  • This is awesome man!!! Can i use the sprite that is in the CapX? I want to try and make a free to play game.

  • hello mike

    thank you for the behaviours

    Could you please add a prismatic joint to your behaviours or help me or guide me to create a prismatic joint behavoiurs my own to use along with yours.

    plz reply as soon as possible <img src="smileys/smiley5.gif" border="0" align="middle" />

  • tnindie

    Here is how I create a prismatic joint in the car physics with the Construct SDK(in this case, the left rear wheel):

    var leftRearJointDef = new Box2D.Dynamics.Joints.b2PrismaticJointDef();

    leftRearJointDef.Initialize(this.PhysBody, this.PhysLBWheel, this.PhysLBWheel.GetWorldCenter(), new Box2D.Common.Math.b2Vec2(1,0));

    leftRearJointDef.enableLimit = true;

    leftRearJointDef.lowerTranslation = leftRearJointDef.upperTranslation = 0;

    leftRearJointDef.collideConnected = false;

    this.LeftBackWheelJoint      = this.PhysWorld.CreateJoint(leftRearJointDef);

    If you need more information than that, I suggest you read the Box2d documentation and/or the Construct Physics files.

  • CodeMasterMike

    thanks for your help

  • Hey yall,

    SO I was tinkering around and wanted to see if I could get the side view car to wrap around the layout. The idea is that the player is on a planet that eventually wraps around. I dont want to do a rotational style game, because the player wont see the actual curvature of the planet they are on, the distance will take some time to go all the way around on.

    So, I tried a few things, including but not limited to trying to put the wrap behavior on all the parts. It just freaks out every time, usually the car gets to the the end of the layoiut and then rtolls off screen. It will sometimes appear on the next side but it will be tweaked out when it arrives.

    What I really want is a totally clean and unnoticeable transition around the other side, so it just feels like you can drive all the way around a planet. ANyone have an idea how to do this with this carphysics behavior?

  • Can someone explain why my car Breaks apart? I have made a small test file to exhibit the behavior (But see no where to attach it). When ever the car hits a jump at a decent angle it breaks apart and does all kind of weird things (spinning, wheels flying everywhere, etc)

  • I have used this to make a top-down car game, But I am stuck at a point.

    My game have 2-3 cars.So instead of making 2 different objects, I just changed the sprite of body to different one, ( they both have same size). But as soon as I change it, the wheels coming out to the sides. I have tried many things, disabling collision etc. but none is success. Can anyone please help me.

    Thanx in advance.

  • Raganork Its not possible to change object like that in realtime, due to the way the physics works. Either use a physics on each car or change the image of the car with the physics instead.

  • Yes. I ran into the same snag but figured it was just something I did wrong...

    I have a single sprite on the screen which is a picture of a car. I added the physics behavior to it. I wanted the car to go from the right side of the screen, and then wrap back in from the left side of the screen. Once the car leaves the screen on the right, it totally flips out -- sometimes you could very briefly see the car appear on the left side of the screen but it is totally flipping out (i.e. spinning, not useable, etc).. then you have to restart the level all over again.

    If there is a simple solution to all a car with the physics behavior wrap from one side of the screen to the other, I'd love to hear it because I'm once again stumped. Thanks.

  • Raganork Its not possible to change object like that in realtime, due to the way the physics works. Either use a physics on each car or change the image of the car with the physics instead.

    How can I change the image of car with the physics ? I want my car to be ready as soon as that layout gets load.

  • Raganork

    Easiest way I can think of at the moment, is to set a image of one car as a animation frame, so you'll have 2 different frames with 2 different images, and then when you want to switch image, you change the current animation frame. But there is surely other and better ways to do it.

  • Raganork

    Easiest way I can think of at the moment, is to set a image of one car as a animation frame, so you'll have 2 different frames with 2 different images, and then when you want to switch image, you change the current animation frame. But there is surely other and better ways to do it.

    I did the same, but that is causing the problem. Can't change the sprite. I am not getting why just changing the sprite is causing the problem.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)