It actually does work. Here’s from the example I shared earlier on Discord:
local FRONTWHEEL = "frontwheel#collisionobject"
local BACKWHEEL = "backwheel#collisionobject"
local BODY = "body#collisionobject"
local FRONT_ID = hash("frontwheel")
local BACK_ID = hash("backwheel")
local V3ZERO = vmath.vector3(0)
function init(self)
local props = {
motor_speed = 20,
enable_limit = false,
enable_motor = true,
max_motor_torque = 100,
}
physics.create_joint(physics.JOINT_TYPE_HINGE, FRONTWHEEL, FRONT_ID, V3ZERO, BODY, vmath.vector3(40, -10, 0), props)
physics.create_joint(physics.JOINT_TYPE_HINGE, BACKWHEEL, BACK_ID, V3ZERO, BODY, vmath.vector3(-40, -10, 0), props)
timer.delay(2, false, function()
local props = {
motor_speed = -20,
enable_limit = false,
enable_motor = true,
max_motor_torque = 100,
}
physics.set_joint_properties(FRONTWHEEL, FRONT_ID, props)
physics.set_joint_properties(BACKWHEEL, BACK_ID, props)
end)
end
The problem was that I had the motor torque set too low and the initial speed too high. With a higher torque the direction of movement changes as expected.