PhaestusFox/bevy_sprite_animation

Tree handle per entity

Opened this issue · 4 comments

So I've got your plugin working on an individual entity, my player.

I then moved my code over to a more generic plugin and just import the correct Components on any entity to make it animated.
Now this works. My enemy entity has a sprite and the sprite moves and changes based on the enemies actions.

Only problem is I can't figure out how to load its own nodetree.

I made a player.node, player.nodetree and enemy.node and enemy.nodetree.

These trees are basically identical atm cause both use a similar spritesheet format that I've split into individual images. Each one points to its own set of frames and their FPSNode name is different.

But my player and enemy will randomly either look like a player or enemy. Never both.
They currently share an Enum AStates and the same attribute name through my generic plugin.

Any ideas?

if you have a program that can render dot graphs installed type D O T and then press + on the num pad it will generate a graph that shows how each entity points into the node trees and how each node connects to each other, it is possible that your nodes have the same id since even tho they are from different trees they need to be able to connect, I suspect both your fps nodes are pointing at the same match node that points to the image to display and some but not all of these images are being overwritten when you load the second trees. each node needs to have a unique name or unique ID specified.

So would I need to give each node tree its own set of ids, unique to all nodetrees?

Can we load multiple nodetrees?

So I got it working now. My 2 node trees shared the same idea.
So I just incremented the enemy nodes and now its loading both.

Is it possible to load separate node trees that aren't connected?
If not is there a Id limit i'll reach if I want to load in many node trees.

I do not currently have a way to load nodes with the same name as two different trees, the trees don't have to be connected in any way, but they will end up connected if you don't specify an id and they have the same name(since the name is used if no id overrides it), I thought people could prefix nodes that would have the same name with the tree they are from like player_fps and enimy_fps. the node id limit is u64::MAX so you will be well out of memory before you are out of ids but you might want a way to manage ids if you are going to have lots, ill open an issue about making trees load "relative" so two trees won't conflict even if they share a path, probably do something like hash the file path + name to get a unique id and have it be a flag at the top of the tree. ps sorry for the slow reply