Driving Physics Help

Hello,
I’m currently working on a 2d car game, and need some help with the car physics. Is there any way I can add a speed limit? And also is there a working slowdown brake I can add to give the game more realism?

6 Likes

ease
math.acos(speed/top speed) + speed

3 Likes

And I thought I was bad at explaining things

Yes, you can do all these things. Unfortunately, I forgot who exactly it was that had achieved this and may be able to help you, so I will summon them both. @Mhx_Air and @AbstractGallery
(sorry if I bothered you guys). Wait a second, I think JR01 did this too.

1 Like

I’m not sure what @John_Shrekinson is referring to, but I like driving simulators, so I’d be happy to help.

If this is a top-down game you could tweak the ship control bundle, that will work.

As for platformer(which I’m assuming it is because you said “2d”), you would probably have to start from scratch. But if you give me the link we can try some different options.

2 Likes

Wait it could’ve been PixelPizza too

1 Like

Here’s my 2d game: Flowlab Game Creator - Free Racer

It’s from a top view perspective, and also FYI the game is a bit sparse.

I’m looking for something like TrackMania blitz, but with a mix of Forza Horizon.

1 Like

Also use wasd or arrow keys to move the car.

1 Like

Ok! I’m letting you know that I’ve been working on something for this and it’s coming along nicely! I’ll let you know when it’s finished. :wink:

Ok! Finished! Just delete the old movement code and add import this. It’s still kind of when using brakes but I figured this is good enough for now!

Copy
{"data":{"behavior":{"v":"2","nodes":[{"inputCount":0,"outputCount":0,"name":"Movement Bundle","behaviorType":"logic.NodeGroup","x":-90,"y":-32,"group":0,"id":"aea6d9bfdec6da4b","isMenuItem":false},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":270,"y":224,"group":"aea6d9bfdec6da4b","id":"aea6d9c380f9ae46","startVal":4,"tag":"steer right"},{"inputCount":2,"outputCount":2,"name":"Rotation","behaviorType":"logic.properties.Rotation","x":450,"y":192,"group":"aea6d9bfdec6da4b","id":"aea6d9c4a9996543"},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":270,"y":416,"group":"aea6d9bfdec6da4b","id":"aea6d9c4453bd840","startVal":0,"tag":"thrust"},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":270,"y":128,"group":"aea6d9bfdec6da4b","id":"aea6d9c548aac64b","startVal":-4,"tag":"steer left"},{"inputCount":0,"outputCount":2,"name":"Keyboard","behaviorType":"logic.triggers.Keyboard","x":-180,"y":512,"group":"aea6d9bfdec6da4b","id":"b382af0f6987d44f","keyCode":87,"repeats":true,"delay":0},{"inputCount":0,"outputCount":2,"name":"Keyboard","behaviorType":"logic.triggers.Keyboard","x":-90,"y":224,"group":"aea6d9bfdec6da4b","id":"b382b0759fe5b943","keyCode":68,"repeats":true,"delay":0},{"inputCount":0,"outputCount":2,"name":"Keyboard","behaviorType":"logic.triggers.Keyboard","x":-90,"y":128,"group":"aea6d9bfdec6da4b","id":"b382b6541c6ab746","keyCode":65,"repeats":true,"delay":0},{"inputCount":0,"outputCount":2,"name":"Keyboard","behaviorType":"logic.triggers.Keyboard","x":-180,"y":736,"group":"aea6d9bfdec6da4b","id":"b3838fa4198d7e43","keyCode":83,"repeats":true,"delay":0},{"gateVal":25,"mode":"less than or equal to","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter","x":450,"y":416,"group":"aea6d9bfdec6da4b","id":"bab1b254ee05684a"},{"inputCount":3,"outputCount":3,"name":"Velocity","behaviorType":"logic.properties.Physics","x":720,"y":544,"group":"aea6d9bfdec6da4b","id":"bab334b2c4ba5242"},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":450,"y":544,"group":"aea6d9bfdec6da4b","id":"bab3fc1314cdde4f","startVal":-1,"tag":"","roundMode":1},{"delay":1.5,"count":0,"version":2,"inputCount":3,"outputCount":1,"name":"Timer","behaviorType":"logic.triggers.Timer","x":270,"y":544,"group":"aea6d9bfdec6da4b","id":"bab42fc1dde4d147"},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":0,"y":480,"group":"aea6d9bfdec6da4b","id":"bac2d1e035191741","_startVal":1,"dataType":2},{"gateVal":0,"mode":"equal to","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter","x":450,"y":288,"group":"aea6d9bfdec6da4b","id":"baca9187e1a1314f"},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":0,"y":736,"group":"aea6d9bfdec6da4b","id":"bacdaf978aec1444","_startVal":1,"dataType":2},{"delay":2.5,"count":0,"version":2,"inputCount":3,"outputCount":1,"name":"Timer","behaviorType":"logic.triggers.Timer","x":270,"y":832,"group":"aea6d9bfdec6da4b","id":"bacdc729c0bab94e"},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":270,"y":736,"group":"aea6d9bfdec6da4b","id":"bacdd92878ef3947","startVal":0,"roundMode":1},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":180,"y":672,"group":"aea6d9bfdec6da4b","id":"bacde2b5b16e374f","startVal":-1,"tag":"","roundMode":1},{"gateVal":-25,"mode":"greater than or equal to","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter","x":450,"y":736,"group":"aea6d9bfdec6da4b","id":"bacdf61bbeddf540"},{"gateVal":0,"mode":"equal to","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter","x":450,"y":640,"group":"aea6d9bfdec6da4b","id":"bad748a76c2eb64b"},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":90,"y":224,"group":"aea6d9bfdec6da4b","id":"bada82f5bc788648","_startVal":0,"dataType":2},{"inputCount":3,"outputCount":1,"name":"Switch","behaviorType":"logic.logic.Switch","x":90,"y":128,"group":"aea6d9bfdec6da4b","id":"bada872c49ff4c47","_startVal":0,"dataType":2}],"links":[{"input_id":"aea6d9c4a9996543i1","output_id":"aea6d9c380f9ae46o0"},{"input_id":"baca9187e1a1314fi0","output_id":"aea6d9c4453bd840o0"},{"input_id":"bab1b254ee05684ai0","output_id":"aea6d9c4453bd840o0"},{"input_id":"aea6d9c4a9996543i1","output_id":"aea6d9c548aac64bo0"},{"input_id":"bada872c49ff4c47i1","output_id":"b382af0f6987d44fo0"},{"input_id":"bada82f5bc788648i1","output_id":"b382af0f6987d44fo0"},{"input_id":"bac2d1e035191741i2","output_id":"b382af0f6987d44fo0"},{"input_id":"bab42fc1dde4d147i0","output_id":"b382af0f6987d44fo1"},{"input_id":"bada82f5bc788648i2","output_id":"b382b0759fe5b943o0"},{"input_id":"bada872c49ff4c47i2","output_id":"b382b6541c6ab746o0"},{"input_id":"bada872c49ff4c47i1","output_id":"b3838fa4198d7e43o0"},{"input_id":"bada82f5bc788648i1","output_id":"b3838fa4198d7e43o0"},{"input_id":"bacdaf978aec1444i2","output_id":"b3838fa4198d7e43o0"},{"input_id":"bacdc729c0bab94ei0","output_id":"b3838fa4198d7e43o1"},{"input_id":"bac2d1e035191741i1","output_id":"bab1b254ee05684ao0"},{"input_id":"bab334b2c4ba5242i2","output_id":"bab1b254ee05684ao0"},{"input_id":"bac2d1e035191741i0","output_id":"bab1b254ee05684ao1"},{"input_id":"aea6d9c4453bd840i2","output_id":"bab3fc1314cdde4fo0"},{"input_id":"bab3fc1314cdde4fi1","output_id":"bab42fc1dde4d147o0"},{"input_id":"aea6d9c4453bd840i2","output_id":"bac2d1e035191741o0"},{"input_id":"bada872c49ff4c47i0","output_id":"baca9187e1a1314fo0"},{"input_id":"bada82f5bc788648i0","output_id":"baca9187e1a1314fo0"},{"input_id":"bab42fc1dde4d147i1","output_id":"baca9187e1a1314fo0"},{"input_id":"bacde2b5b16e374fi1","output_id":"bacdaf978aec1444o0"},{"input_id":"bada872c49ff4c47i0","output_id":"bacdc729c0bab94eo0"},{"input_id":"bada82f5bc788648i0","output_id":"bacdc729c0bab94eo0"},{"input_id":"bacdd92878ef3947i2","output_id":"bacdc729c0bab94eo0"},{"input_id":"bad748a76c2eb64bi0","output_id":"bacdd92878ef3947o0"},{"input_id":"bacdf61bbeddf540i0","output_id":"bacdd92878ef3947o0"},{"input_id":"bacdd92878ef3947i2","output_id":"bacde2b5b16e374fo0"},{"input_id":"bab334b2c4ba5242i2","output_id":"bacdf61bbeddf540o0"},{"input_id":"bacdaf978aec1444i1","output_id":"bacdf61bbeddf540o0"},{"input_id":"bacdaf978aec1444i0","output_id":"bacdf61bbeddf540o1"},{"input_id":"bada872c49ff4c47i0","output_id":"bad748a76c2eb64bo0"},{"input_id":"bada82f5bc788648i0","output_id":"bad748a76c2eb64bo0"},{"input_id":"bacdc729c0bab94ei1","output_id":"bad748a76c2eb64bo0"},{"input_id":"aea6d9c380f9ae46i1","output_id":"bada82f5bc788648o0"},{"input_id":"aea6d9c548aac64bi1","output_id":"bada872c49ff4c47o0"}]}}}

Also, turn off enable rotation.

image

Okay, so how do I copy and paste the code in? I’m still a bit new to how the code works.

1 Like

You copy it then click anywhere within the behavior editor. Next, click Import on the small menu that pops up. Then, paste your copied behaviors into the import text box. Finally, click Ok.

1 Like

okay thank you so much again. :slight_smile:

2 Likes

No problem! If you need any help just @AbstractGallery!

1 Like

@AbstactGallery I just imported the code into the game and saved it. Everything is fine but when I move the car, it’s very laggy.

2 Likes

Is there any way to fix that issue?

2 Likes

You’re welcome :slightly_smiling_face:!

1 Like

I don’t think lag is your issue. I think you may be experiencing one of the bugs with the code.
image

Does it happen when you drive one direction and then change to the other?

Yeah, it does, so like when to go forward and then press backward, it starts to glitch out for a while and then go backward. I think it’s because of the conflicting direction speeds.

1 Like

Ok, that’s what I thought. I’ll try and figure it out tonight.

I was also thinking. Could I create a DEV team so you and I can work on the game together? It would also give you unlimited objects and levels, along with all the other perks of Indie.

If not that’s totally fine, I understand.

Oh! if you do want to DEV the game will be on my games list, but it’ll we say that it was by our team and not just me. Let me know if you want to.