I'm trying to optimize using servers, and I need help creating an object using the PhysicsServer (PS) and VirtualServer (VS).
Here's what I would like to create, as described by how I would make it in the Editor. I would like to have a RigidBody with a CollisionShape, an Area with another CollisionShape, and a CSGSphere. Looking something like this:
---- ---- CollisionShape
What I've done so far is to try to create a single instance in a Spatial node with the following script. I can't figure out how to attach the area to the RigidBody however.
# Create the body.
body = PhysicsServer.body_create()
PhysicsServer.body_set_mode( body, PhysicsServer.BODY_MODE_RIGID )
bodyshape = PhysicsServer.shape_create( PhysicsServer.SHAPE_SPHERE )
# Create area
area = PhysicsServer.area_create()
areashape = PhysicsServer.shape_create( PhysicsServer.SHAPE_SPHERE)
PhysicsServer.area_add_shape ( area, areashape)
# Set space, so it collides in the same space as current scene.
PhysicsServer.body_set_space( body, get_world().space )
PhysicsServer.area_set_space( area, get_world().space )
# Move initial position.
PhysicsServer.body_set_state(body, PhysicsServer.BODY_STATE_TRANSFORM, Transform(Vector3(0,0,0), Vector3(10,0,0)) )
PhysicsServer.body_set_force_integration_callback(body, self, "_body_moved", 0)
- How to create the above-described object using VS and PS?
- A subquestion: how to attach an Area to RigidBody using VS and PS?
Thanks a lot in advance,