Hi
Now I have a simple scene. A plane with multiple shapes on it. Now I'd like to move them all together but keeping them relative position relationship. Is there any simple way to do it with regular API?
any good way to move multiple shapes with regular API
Re: any good way to move multiple shapes with regular API
Are the shapes static or dynamic?
How do you mean move them all together? Do you want to instantaneously change the position via API (e.g.
So you want to move a group of objects as if it is one object?
How do you mean move them all together? Do you want to instantaneously change the position via API (e.g.
sim.setObjectPosition
)?So you want to move a group of objects as if it is one object?
Re: any good way to move multiple shapes with regular API
For simple shapes, dynamic or static, you could do something like:
Cheers
Code: Select all
sim.setThreadAutomaticSwitch(false) -- only needed if running inside of a threaded child script
local dummy=sim.createDummy(0.01) -- created at the origin
sim.setObjectParent(shape1Handle,dummy,true)
sim.setObjectParent(shape2Handle,dummy,true)
...
sim.setObjectParent(shapeNHandle,dummy,true)
sim.setObjectPosition(dummy,-1,newPositionForDummy)
sim.removeObject(dummy)
sim.resetDynamicObject(shape1Handle) -- only needed if shapes are non-static
sim.resetDynamicObject(shape2Handle) -- only needed if shapes are non-static
...
sim.resetDynamicObject(shapeNHandle) -- only needed if shapes are non-static
sim.setThreadAutomaticSwitch(true) -- only needed if running inside of a threaded child script