Moving mesh collected by RBC

Hello, I want to use RBC, but I can’t get it to work (it’s the first time I’m using it, sorry if the question is trivial). In the following example, I have a cube, I collect it, and on an event I try to move it. But it doesn’t move. Where is my mistake? Very thanks!

import direct.directbase.DirectStart
from pandac.PandaModules import RigidBodyCombiner, NodePath, Vec3
from direct.showbase import DirectObject

class World( DirectObject.DirectObject ):

  def __init__( self ):
    self.rbc = RigidBodyCombiner( 'rbc' )
    self.rbcnp = NodePath( self.rbc )
    self.rbcnp.reparentTo( render )

    self.box = loader.loadModel( 'models/box' )
    self.box.setPos( 0, 0, 0 )
    self.box.reparentTo( self.rbcnp )
 
    self.rbc.collect()

    base.camera.setPos( 0, -5, 5 )
    base.camera.lookAt( 0, 0, 0 )
    base.disableMouse()	
    self.accept( 'f1', self.moveBox )
	
  def moveBox( self ):
    self.box.setPos( Vec3( 1, 0, 0 ) )

World()
run()

Change this line:

self.box.setPos( Vec3( 1, 0, 0 ) ) 

To:

self.box.setPos( self.box, Vec3( 1, 0, 0 ) ) 

Also, change this line at startup:

self.box.setPos( 0, 0, 0 )

to:

self.box.setPos( 0.001, 0, 0 )

This is necessary because, according to the documentation for RBC.collect():

So, you need to have a non-identity transform initially (or set the preserve_transform flag), in order to identify the node as a “moving” node. Otherwise the RBC will optimize away any further attempts to move it.

David

Very thanks, these hints solve my problem!