Godot Version
4.2.2
Question
I’m probably being dumb, but I’m struggling to see how you set data for more complex physics intersection check shapes like Cylinder (Radius and Height) and Capsules (Radius and Height)?
(I use C# mostly and the code below is a first stab at some dynamic collision work - I’ll lose the reflection “else if’ing” and likely switch case it at some stage)
The code:
Rid shapeRid;
if (_currentSpawnCmd.spawnCollisionCheckShape3D is BoxShape3D)
{
shapeRid = PhysicsServer3D.BoxShapeCreate();
PhysicsServer3D.ShapeSetData(shapeRid, (_currentSpawnCmd.spawnCollisionCheckShape3D as BoxShape3D).Size);
}
else if (_currentSpawnCmd.spawnCollisionCheckShape3D is SphereShape3D)
{
shapeRid = PhysicsServer3D.SphereShapeCreate();
PhysicsServer3D.ShapeSetData(shapeRid, (_currentSpawnCmd.spawnCollisionCheckShape3D as SphereShape3D).Radius);
}
else if (_currentSpawnCmd.spawnCollisionCheckShape3D is CylinderShape3D)
{
shapeRid = PhysicsServer3D.CylinderShapeCreate();
PhysicsServer3D.ShapeSetData(shapeRid, (_currentSpawnCmd.spawnCollisionCheckShape3D as CylinderShape3D).Radius);
PhysicsServer3D.ShapeSetData(shapeRid, (_currentSpawnCmd.spawnCollisionCheckShape3D as CylinderShape3D).Height); // How can this work as a variant vs Radius?
}
else if (_currentSpawnCmd.spawnCollisionCheckShape3D is CapsuleShape3D)
{
shapeRid = PhysicsServer3D.CapsuleShapeCreate();
PhysicsServer3D.ShapeSetData(shapeRid, (_currentSpawnCmd.spawnCollisionCheckShape3D as CapsuleShape3D).Radius);
PhysicsServer3D.ShapeSetData(shapeRid, (_currentSpawnCmd.spawnCollisionCheckShape3D as CapsuleShape3D).Height);// How can this work as a variant vs Radius?
}