How to structure Ability System

Im working on an ability System for my vampire survivors like (shoot em up). I made a base ability and base aoe ability and etc. all are actors.
I ran into a problem because i want to safe the level in the ability, but i instantiate the ability from class when casting. So i cant update level or change cooldown inside the ability.
How could i go about this. I was thinking about saving the level of each ability in a seperet component, but that feels not right.
Also i though about making one component for each ability and attach them to the player, but should you use components if it is only used by one actor?
Maybe someone with more experience could give a little point in the right direction?

components would be fine, or even a struct if you just want to keep it really simple.

2 Likes

As above, comps will work well for this.

  • make a base component class
    – shared stats go here
    – leveling it up
    – dispatchers
    – auto firing
    – saving
    – and so om
  • make a child of the base that is a projectile
  • make a child of the base that is an AOE effect
  • make a child of the base that is an OT effect
  • any other child class whose effects bring something new / unique enough to warrant a subclass

Spawn comps dynamically on the player with:

image

Before you spawn it, look up whether the player already has one and level it up instead.

1 Like

Thank you, this is exactly what i thought about, but isnt it bad practice to use a component for something like that.
In my understanding components should be used for code thats shared between multiple actors

components should be used for code thats shared between multiple actors

I’d replace should be with can be in that statement. They are useful and efficient when shared but that should not limit their use, imho. They’re lightweight, versatile and easy to maintain.

  • if my character needs a backpack with a built-in full inventory management system, I’ll make it into an Actor Component, attach it to the player, encapsulate all logic inside and roll with it. And no one else is getting a backpack in the game, and there will be no sub classes either. I’ve just decluttered a very busy player class who does not really need to know how to split a stack of potions.

  • in a VR game, my right hand can grab onto everything and toss it. It’s a Scene Component and there is only one in the entire game. I say it’s fine to use a component.

  • in a first person shooter, the 3d HUD is a Widget Component. No one else is getting one because AI bots don’t need one.

Sharing is caring but that’s not all. :innocent:


Besides that, nothing is stopping you from granting those projectile components to some of the sharpshooting mobs. You could even:

  • base ability class
    – projectile
    — projectile Player
    — projectile AI

The AI and the Player are given respective projectile comps.

Alright this makes a lot of sense! I will try that definitely.
Btw you are a HERO. I read your responses all the time in the forum, thank you so much!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.