--Here we "fake" the transportation pads with a single static rectangle that we dynamically reset
-- at each simulation pass (while not forgetting to set its initial velocity vector)
I am trying to send cuboids along a conveyor. When I commented on the whole code below these two comments, the conveyor belt still keeps working but cuboids do not move on the belt. Why does this happen?
The part I commented out :
Code: Select all
local relativeLinearVelocity={beltVelocity,0,0}
-- Reset the dynamic rectangle from the simulation (it will be removed and added again)
sim.resetDynamicObject(forwarder)
-- Compute the absolute velocity vector:
local m=sim.getObjectMatrix(forwarder,-1)
m[4]=0 -- Make sure the translation component is discarded
m[8]=0 -- Make sure the translation component is discarded
m[12]=0 -- Make sure the translation component is discarded
local absoluteLinearVelocity=sim.multiplyVector(m,relativeLinearVelocity)
-- Now set the initial velocity of the dynamic rectangle:
sim.setObjectFloatParameter(forwarder,sim.shapefloatparam_init_velocity_x,absoluteLinearVelocity[1])
sim.setObjectFloatParameter(forwarder,sim.shapefloatparam_init_velocity_y,absoluteLinearVelocity[2])
sim.setObjectFloatParameter(forwarder,sim.shapefloatparam_init_velocity_z,absoluteLinearVelocity[3])