using Godot; using System; /** * Used to auto-generate Meshes that are the same as collision objects, for convenience. * makes a new MeshInstance3D as a sibling (child of this object's parent) * and applies the same shape, tranform, and scale. */ public partial class AutoMeshInstance : CollisionShape3D { public override void _Ready() { base._Ready(); MeshInstance3D mi = new MeshInstance3D(); if (Shape is BoxShape3D boxshp){ BoxMesh m = new BoxMesh(); m.Size = boxshp.Size; mi.Mesh = m; } if (Shape is CylinderShape3D cylshp){ CylinderMesh m = new CylinderMesh(); m.TopRadius = cylshp.Radius; m.BottomRadius = cylshp.Radius; m.Height = cylshp.Height; mi.Mesh = m; } if (Shape is CapsuleShape3D){} if (Shape is SphereShape3D){} mi.Rotation = Rotation; mi.Position = Position; GetParent().CallDeferred("add_child", mi); } }