Why are wheels not colliding anymore?

Wheel bodies stopped colliding with car in my project. I throroughly checked every char in the code, nothing worked.

Since I’m noobie, I tried the Corona University tutorial.

It worked in the beginning, then… suddenly the wheels were not colliding anymore.

I closed the project, the Corona Simulator, deleted sandbox and even rebooted my computer.

Nothing worked.

I started a new project with only main.lua (it’s the coronaU tutorial code):
 

local physics = require( "physics") physics.start( ) physics.setGravity( 0, 9.8 ) physics.setDrawMode( "hybrid" ) local joints = {} local vehicleBody = display.newRect( 10, 10, 100, 20 ) physics.addBody( vehicleBody) vehicleBody.x, vehicleBody.y = display.contentCenterX, display.contentHeight - 120 vehicleBody.isFixedRotation = true local wheelParams = { bounce = 0, friction = 1, radius = 20 } local wheelA = display.newCircle( 0, 0, 20 ) physics.addBody( wheelA, wheelParams ) wheelA.x, wheelA.y = vehicleBody.x - 25, vehicleBody.y + 30 local wheelB = display.newCircle( 0, 0, 20 ) physics.addBody( wheelB, wheelParams ) wheelB.x, wheelB.y = vehicleBody.x + 25, vehicleBody.y + 30 local wheelSpringFrequency = 20 local wheelSpringDampingRatio = 0.8 joints[#joints + 1] = physics.newJoint( "wheel", vehicleBody, wheelA, wheelA.x, wheelA.y, 0, 1 ) joints[#joints].springFrequency = wheelSpringFrequency joints[#joints].springDampingRatio = wheelSpringDampingRatio joints[#joints + 1] = physics.newJoint( "wheel", vehicleBody, wheelB, wheelB.x, wheelB.y, 0, 1 ) local ground = display.newRect( 0, 0, display.contentWidth, 80 ) physics.addBody( ground, "static", {bounce = 0, friction = 1} ) ground.x, ground.y = display.contentCenterX, display.contentHeight - ground.contentHeight/2 wheelA:applyTorque( 2.8 ) wheelB:applyTorque( 2.8 )

~

Can anyone confirm that the wheels are not colliding!?!? Any idea why!?

Thanks.

Hi @orlando2bjr,

If you use joints to attach the wheels to the vehicle body, the wheels will not register collisions with the body. Currently there is no way to change this. If it’s imperative that the wheels must collide with the body, you might consider attaching another body piece below the vehicle body (a thin basic rectangle perhaps), attach that to the main vehicle body via a weld joint, and then attach the wheels to the main vehicle body. In that way, the wheels would be joined to the main vehicle body, but not the “underneath body piece”, so they should register collisions with that piece.

Hope this helps,

Brent

I really helped! :smiley:

I hope it can be switched on and off in the future, or even a Gotcha section in the documentation would help.

Thanks a lot, Brent.

Hi @orlando2bjr,

If you use joints to attach the wheels to the vehicle body, the wheels will not register collisions with the body. Currently there is no way to change this. If it’s imperative that the wheels must collide with the body, you might consider attaching another body piece below the vehicle body (a thin basic rectangle perhaps), attach that to the main vehicle body via a weld joint, and then attach the wheels to the main vehicle body. In that way, the wheels would be joined to the main vehicle body, but not the “underneath body piece”, so they should register collisions with that piece.

Hope this helps,

Brent

I really helped! :smiley:

I hope it can be switched on and off in the future, or even a Gotcha section in the documentation would help.

Thanks a lot, Brent.