I am trying to figure a good way to create the battle system of a game. The game is fast paced and the gameplay needs to be precise (think hack n slash)

What I would like to achieve is a simple and unified system that could manage any type of attacks, that could be tweaked.

My first idea is to use physics shape: For example an arrow will just be a little capsule moving forward, an explosion would be a growing sphere collider, and melee combat could be done by spawning a box in front of the player.

One problem I have with this is that I'd like to have an authoritative server for multiplayer, which means I shouldn't use too much actual physics.

So, is there any standard way people program these sort of systems, do you know any good starting point better than just using physics?

  • 3
    \$\begingroup\$ Fake it. Decide if the projectile is going to hit when it's launched using raycasting (for fast projectiles) or decide that a melee attack hits with a hitbox test when the attack is triggered. \$\endgroup\$
    – House
    May 2, 2014 at 17:15

1 Answer 1


Fundamentally, you're going to be doing collision detection with what are essentially physics volumes (simple primitive shapes like spheres and cylinders) to achieve what you want, unless you want to start sacrificing accuracy and doing even simpler ray checks. Consequently, it makes some sense to use a physics API for this. These sort of computations are exactly the kind of things physics APIs tend to do well.

Guild Wars 2 used basic physics volumes like you are describing for server-side collision detection between attacks and characters and the like. It is a viable plan; just try to keep your collision volumes as simple as possible for the effect in question and profile when you discover bottlenecks.

You may also want to do client-side prediction of the collisions, using physics or simpler checks, to avoid latency and keep your game feeling responsive.

  • \$\begingroup\$ Thanks for the answer. I wasn't sure my idea was efficient or if there wasn't anything more clever to do, but it seems pretty viable \$\endgroup\$
    – nialna2
    May 2, 2014 at 20:14
  • 1
    \$\begingroup\$ The efficiency will come from implementation; you can still build it poorly :P \$\endgroup\$
    – user1430
    May 2, 2014 at 20:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .