• Advertisement
Sign in to follow this  

Spells in entity component systems

This topic is 1477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

I'm a newcomer to this forums and I hope that there are others more experienced in entity component systems over here. I've just started working on a game using the Ash framework and I've sort of gotten a grasp on it. The game is a sidescroller action "aim with mouse" type of game but with spells instead of guns. I'm having a hard time making a spell system though. I'll use a simple example here:

 

the main character has 3 spells: fireball, water bolt and freeze . Now the "wizard entity" has a child entity (basically they share the same position component but with an offset) called "staff". Now my staff entity also has a "staff component" which holds all the properties of the spell im about to cast including its lifetime, element, and cooldown. 

Now how would I make it that pressing "Q" or "E" changes my currently equipped spell?

 

 

Share this post


Link to post
Share on other sites
Advertisement

I would make the staff component hold only a reference to the current spell (could be a child entity). You would then have 3 instances of a Spell entity, one for each of your spells, and these would contain in a component all the spell info like cooldown, cost, etc.. Then just keep somewhere a list of all spells your character has, and by pressing Q or E, you just remove the child entity from the staff and add a new entity that is the next spell in your list. The spell entity itself could have some animation specific to the spell and you could be showing it. Very simple imho.

 

I hope you got the idea :)

Share this post


Link to post
Share on other sites

I would make the staff component hold only a reference to the current spell (could be a child entity). You would then have 3 instances of a Spell entity, one for each of your spells, and these would contain in a component all the spell info like cooldown, cost, etc.. Then just keep somewhere a list of all spells your character has, and by pressing Q or E, you just remove the child entity from the staff and add a new entity that is the next spell in your list. The spell entity itself could have some animation specific to the spell and you could be showing it. Very simple imho.

 

I hope you got the idea smile.png

I actually thought of something similar after posting my question. I thought it was too simple to be right though hehe.

Thanks for your help I'm gonna try it out now :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement