There’s quite a number of ways to accomplish that. Especially with cars.
Here’s a simple example of what you could do:
local physics = require("physics") physics.start() physics.setDrawMode( "hybrid" ) physics.setGravity( 0, 0 ) -- create the car local car = display.newRect( display.contentCenterX, display.contentCenterY, 30, 20 ) physics.addBody( car, "dynamic", { density=1 } ) car.isFixedRotation = true -- change the car's direction local carSpeed = 40 local function randomDirection() local randomDirection = math.random( -180, 180 ) car.rotation = randomDirection car.angularVelocity = 0 randomDirection = math.rad( randomDirection ) car:setLinearVelocity( math.cos(randomDirection)\*carSpeed, math.sin(randomDirection)\*carSpeed, car.x, car.y ) end timer.performWithDelay( 2000, randomDirection, 0 ) -- create obstacles local obstacle = {} local obstacleCount = 25 for i = 1, obstacleCount do obstacle[i] = display.newCircle( math.random( 20, 460 ), math.random( 20, 300 ), 12 ) physics.addBody( obstacle[i], "dynamic", { density=0.2, radius=12 } ) end
This is just a simple example. “Proper cars” would require more work as they aren’t just boxes propelled from their centre, but instead they are pulled by their wheels. Meaning the cars can slide sideways, their rotation isn’t locked, they either have front wheel, back wheel or four wheel dive, etc. This just just meant to give you and idea.
Some other steps that you can take, if you want to “fake transitions” is to send an object in some direction and calculate how long it would take that object to reach the destination or you could add an invisible small circle for the object to collide with, which would be located at the destination, etc.
Happy coding!