Can't make applyForce do anything

Here’s my example. I expect that when I press the applyForce button, the box should go flying. It doesn’t move at all.

What am I missing? Thanks!

-- ApplyForce?

function setup()
    scene = craft.scene()
    --scene.physics.gravity = vec3(0,0,0)
    createFloor()
    createBox()
    scene.camera:add(OrbitViewer, vec3(0,0,0), 20, 1, 20)
    angle = 0
    parameter.action("Force", applyForce)
end

function applyForce()
    BoxBody:applyForce(vec3(100,100,100))
end

function update(dt)
    scene:update(dt)
end

-- Called automatically by codea 
function draw()
    update(DeltaTime)
    scene:draw()	
end

function createBox()
    local box = scene:entity()
    local body = box:add(craft.rigidbody, DYNAMIC, 1) -- mass
    body.restitution = 0.8
    BoxBody = body
    box:add(craft.shape.box, vec3(1,1,1))
    box.model = craft. model.cube(vec3(1,1,1))
    box.material = craft.material(asset.builtin.Materials.Specular)
    box.material.map = readImage(asset.builtin.Blocks.Missing)
    return box
end

function createFloor()
    local floor = scene:entity()
    local body = floor:add(craft.rigidbody, STATIC)
    body.restitution = 0.9
    floor:add(craft.shape.box, vec3(25, 0.01, 25))
    floor.model = craft.model.cube(vec3(25, 0.1, 25))
    floor.y = -1.05
    floor.material = craft.material(asset.builtin.Materials.Specular)
    floor.material.map = readImage(asset.builtin.Blocks.Brick_Grey)
    floor.material.offsetRepeat = vec4(0,0,25,25)
    return floor
end

Curiously, once in a while it moves. Very infrequently.

@RonJeffries When I tap on Force, the box jumps to the left. If I uncomment the physics.gravity line, then it continues in a up/left direction. So it appears to work for me.

Weird. Doesn’t work on either of my iPads. Once in a long while it moves.

@John any idea what’s up?

@RonJeffries I deleted your example on my iPad and loaded it again. It still works. With gravity, it jumps to the left on the floor. Without gravity, it continues to move up and left. I’ll try it on my other iPads.

on my fastest ipad it moved very occasionally. even putting huge numbers in the vector does nothing.

Doesn’t move at all for me when testing on iPhone 8.

ah! if i tap while it is still settling, it responds. if i wait till it’s dead stopped, it doesn’t go. it’s as if physics stops running if nothing is going on.

It works on my iPad Air 3, iPad Air 4 and iPad Pro 1 and iPhone 8 SE.

Tried it on my iPad Air 1 and it worked.

does it work even if you wait a long time, letting the falling one completely settle and then press the button?

@RonJeffries Try adding this.

    box.sleepingAllowed=false

That didn’t seem to work. If I wait 2 minutes, the Force button doesn’t work. I thought for sure the sleepingAllowed= false would work.

PS. Just waiting about 10 sec and it doesn’t work.

body.sleepingAllowed makes it move almost every time. I wonder what sleeping is.

it’s body, not box tho.

it usually works for me, but not always. if i’m to document it, i’m like to know what’s up.

with sleep permission false, i display awake or asleep in draw depending on BixBody.awake and it is always false, i.e. not awake.

Very weird.

@RonJeffries That was my mistake. The sleepingAllowed should be applied to the rigidbody variable, not the entity variable.

interestingly even with that in place it doesn’t always work. I checked to be sure physics wasn’t paused. it wasn’t. i hope @John or @Simeon can take a look.

@RonJeffries I waited 3 minutes and it still worked.

@RonJeffries That’s weird, it’s supposed to wake up the rigidbody automatically whenever you call addForce / addTorque, must be a bug