Car Sidescroller

I’m looking for advice on how to approach a car side-scroller game using Corona’s physics and joints. I’m not too sure where to start.

I’m guessing I would need to split the car up between body and wheels; and the wheels would use wheel joints, correct?

I took a look at the wheel.lua in the sample code that Corona provides (SampleCode/Physics/Joints). The body seems to be very floppy/springy on top of the wheels. I’d prefer as if the wheels were more fixed to the body. I tried to adjust some of the values to lessen the spring (to make it more like a car) but nothing works. What can I do to deal with this?

Any other tips?

Thank you!

I can’t give you much advice, but I do believe I have a basic example:

http://github.com/roaminggamer/CoronaGeek/tree/master/Hangouts/Sampler/sampler/examples/simple_car

You can get the whole repository here:

https://github.com/roaminggamer/CoronaGeek

, or this zip should also have the example in it:

http://github.com/roaminggamer/CoronaGeek/raw/master/Hangouts/Sampler/sampler.zip

While you’re looking at my stuff, don’t forget my (huge) Free Stuff repository:

http://github.com/roaminggamer/RG_FreeStuff

https://www.youtube.com/watch?v=jXAEl2jXMBI

Thanks! :slight_smile:

Marked as solved with this very helpful example regarding car physics.

Still open to any other tips or advice should anyone have any (especially any regarding side-scrolling)! For instance, should I have the camera following my car? Or should my camera stay in place while environmental items scroll onto screen?

I’d go with camera tracking car, but only horizontally.

This may or may not help, but its a start:

http://github.com/roaminggamer/SSKLegacy/blob/master/ssk/RGCamera.lua

I wonder how to do the “ground” object with physics. How is it possible to move physics shapes on which the car is driving on?

I want to create a sample with the car and a layered background created in Tiled editor. Now I have the tiles and I add physics to them for the ground. I can’t get the physics bodies to move when moving the layer itself.

What am I missing here?

Note: Hi.  You may want to start a new thread.  My answer and the original question are not about or using tiled so there isn’t a direct 1:1 relationship and it may muddle things a bit to talk about that here.

I also suspect you’re using Dusk or another module to load your Tiled level?  I

That said here is a brief answer.

Don’t move layers independently of each other  to move physics bodies or you will get weird results.  This is a limitation of the way Corona uses Box2D and a well known phenomenon.

You can however move a parent group that contains child groups where those child groups contain physics objects.   These objects will maintain their relative placement to each other.

Also, are you physics rendering debug mode?   Do so and see what your bodies are doing.

Thank you for your fast answer and help! Much appreciated!

I can’t give you much advice, but I do believe I have a basic example:

http://github.com/roaminggamer/CoronaGeek/tree/master/Hangouts/Sampler/sampler/examples/simple_car

You can get the whole repository here:

https://github.com/roaminggamer/CoronaGeek

, or this zip should also have the example in it:

http://github.com/roaminggamer/CoronaGeek/raw/master/Hangouts/Sampler/sampler.zip

While you’re looking at my stuff, don’t forget my (huge) Free Stuff repository:

http://github.com/roaminggamer/RG_FreeStuff

https://www.youtube.com/watch?v=jXAEl2jXMBI

Thanks! :slight_smile:

Marked as solved with this very helpful example regarding car physics.

Still open to any other tips or advice should anyone have any (especially any regarding side-scrolling)! For instance, should I have the camera following my car? Or should my camera stay in place while environmental items scroll onto screen?

I’d go with camera tracking car, but only horizontally.

This may or may not help, but its a start:

http://github.com/roaminggamer/SSKLegacy/blob/master/ssk/RGCamera.lua

I wonder how to do the “ground” object with physics. How is it possible to move physics shapes on which the car is driving on?

I want to create a sample with the car and a layered background created in Tiled editor. Now I have the tiles and I add physics to them for the ground. I can’t get the physics bodies to move when moving the layer itself.

What am I missing here?

Note: Hi.  You may want to start a new thread.  My answer and the original question are not about or using tiled so there isn’t a direct 1:1 relationship and it may muddle things a bit to talk about that here.

I also suspect you’re using Dusk or another module to load your Tiled level?  I

That said here is a brief answer.

Don’t move layers independently of each other  to move physics bodies or you will get weird results.  This is a limitation of the way Corona uses Box2D and a well known phenomenon.

You can however move a parent group that contains child groups where those child groups contain physics objects.   These objects will maintain their relative placement to each other.

Also, are you physics rendering debug mode?   Do so and see what your bodies are doing.

Thank you for your fast answer and help! Much appreciated!