Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spawing Entities Dynamically #335

Open
rdelfin opened this issue Sep 29, 2024 · 3 comments
Open

Spawing Entities Dynamically #335

rdelfin opened this issue Sep 29, 2024 · 3 comments

Comments

@rdelfin
Copy link

rdelfin commented Sep 29, 2024

Sorry if this is something that's mentioned elsewhere but I couldn't find any issues.

Is there currently a way of manually spawning a new entity based off an entity type in LDtk? To give an example, I have a game where entities spawn based on a specific event from specific spots on the map (the spawn points are themselves entities). What I'd like to do is use the "entity" objects in LDtk as a template to spawn a new entity. That way I can use the spritesheet as loaded in LDtk. Is this possible?

@TurtIeSocks
Copy link

TurtIeSocks commented Oct 8, 2024

+1 here, also interested. Or would be curious to hear if this is the wrong approach entirely and what would be a better way! I suppose the reasoning for why this isn't possible/apparent are generally covered by #258

@rdelfin
Copy link
Author

rdelfin commented Oct 19, 2024

Yeah, that's a fair point! Maybe it's easier to have my own custom bundles and logic for doing that in game instead

@TurtIeSocks
Copy link

Yeah, that's a fair point! Maybe it's easier to have my own custom bundles and logic for doing that in game instead

Since my comment I did actually manage to make this "work". I'll PR some example code someday but basically I have my bundles for each entity that I treat as templates, spawn them in at startup and then turn their visibility to hidden. Then when I want to spawn them in code, I query for a unique component marker that I've inserted into the template entities, and clone each of the components that I want to the new entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants