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
@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.
@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.
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.
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.