Skip to content
Discussion options

You must be logged in to vote

After the mesh is created, the original RegularPolygon is discarded. If you want to keep it around to access it later, a handy place to store it would be an additional component to your Ball entity.

// `RegularPolygon` doesn't impl `Component`, so we need to wrap it in our own type.
#[derive(Component)]
struct BallShape(RegularPolygon);

// Create a regular polygon with a circumcircle radius of 0.5, or diameter of 1.0.
// This will be scaled by `BALL_DIAMETER` later.
let shape = RegularPolygon::new(0.5, 6);
let mesh_2d_handle = meshes.add(Mesh::from(shape));

commands.spawn((
    /* snipped for brevity */
    Ball,
    BallShape(shape)
));

You could then add it to the query in your update…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rmoraes92
Comment options

@rparrett
Comment options

rparrett Jun 1, 2024
Collaborator

Answer selected by rmoraes92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants