[SOLVED] How to: Adding RigidBody and Collider via Script....?

How can one add a RigidBody and Collider via Script.

Tried the following… Collider with Sphere-Shape to RigidBody

RigidbodyComponent rigidBody = new RigidbodyComponent();
SphereColliderShape collider = new SphereColliderShape(false, GlobalConst.FINGERTIP_SCALE / 2);

// ---- this works from syntax view, but does not actually add the collider since when I add the entity to scene it says that there are no colliderShapes to the physics-component**
rigidBody.ColliderShape = collider;
// ---- this takes an "IInlineColliderShapeDesc" which I haven't found in the inheritance tree.** 
rigidBody.ColliderShapes.Add(collider);

rigidBody.IsKinematic = true;
rigidBody.Enabled = true;
rigidBody.IsTrigger = true;

entity.Add(rigidBody);

Thx,
Martin

Solution: Has to be inherited from SphereColliderShapeDesc

1 Like