Jump to content

  • Log In with Google      Sign In   
  • Create Account

Spells in entity component systems


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 camel rider   Members   -  Reputation: 121

Like
0Likes
Like

Posted 04 January 2014 - 07:13 AM

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?

 

 



Sponsor:

#2 michalferko   Members   -  Reputation: 618

Like
0Likes
Like

Posted 04 January 2014 - 08:25 AM

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 :)



#3 camel rider   Members   -  Reputation: 121

Like
0Likes
Like

Posted 04 January 2014 - 09:27 AM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS