Remove entity from scene #557
Answered
by
Cfomodz
simplestory
asked this question in
Q&A
-
|
Is there any way to remove an entity from scene? In my case, I will randomly add some entity ( |
Beta Was this translation helpful? Give feedback.
Answered by
Cfomodz
Dec 2, 2025
Replies: 1 comment 1 reply
-
|
Genesis does not provide a built-in SolutionRebuild the scene without the unwanted entity: # Store entity specifications
entity_specs = [] # List of (morph, material, surface) tuples
# Destroy current scene
scene.destroy()
# Create new scene
scene = gs.Scene()
# Re-add only desired entities
for morph, material, surface in entity_specs:
if should_keep(entity): # Your condition
scene.add_entity(morph, material, surface)
scene.build() |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
simplestory
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Genesis does not provide a built-in
remove_entity()method. Once entities are added and the scene is built, they cannot be safely removed at runtime.Solution
Rebuild the scene without the unwanted entity: