Search Unity

Matched combat blocks parry and dodge in an rpg game.

Discussion in 'Game Design' started by dlich, Apr 25, 2019.

  1. dlich

    dlich

    Joined:
    Apr 21, 2019
    Posts:
    11
    Hello. I'm kind of a beginner to unity and gamedev in general and currently working on my own game as a way to learn. The game is a top isometric(?)-down view rpg, like Diablo, neverwinter nights or dungeon siege if you know any of these.

    Now let's get straight to the issue. Inspired by the way combat works in neverwinter nights, I am trying to implement a system, where characters attacks match opponents blocks, parry and dodges. For example if the attacker attacks from above and the attacked character successfully passes block check, it will play the appropriate "blockTop"(just an example name) animation. Every type of attack will have an appropriate block/ dodge/ parry animation. This way the combat will look realistic compared to a situation where a character just swings his weapon through the body of the opponent and a "blocked" text floats up above.

    Now, I've thought of a way to do it, but I'm not sure it's the optimal simplest solution, so I would like some feedback if possible.
    The idea is simple:
    - Decide on a few attack patterns(directions) that every weapon attack animation will follow. For example: left side, up, right side, straight thrust to the chest.
    - make animations for attacks according to the patterns and appropriate parry, dodge, block, hit animations in response.
    - call appropriate animations from script( combat manager or actions manager) depending on the positions of characters, hit or miss, attack direction, etc...

    Now, there are a few problems with my aproach:
    - How do I make animations in 3d software, like blender, to match positions of characters, timings etc. Maybe mark some points in space where the hit connects and somehow export them to unity?
    - The approach seems to bee too crude and complex for the task? Maybe there's a simpler solution that I'm missing?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Welcome!

    First, this is an implementation question, not a game design question — it's clear you've already settled on your game design. So, for future reference, the Getting-Started forum would be more appropriate. But since you're here let's go with it.

    I don't believe there is any simpler solution. To get the effect you describe, you simply have to have a parry/dodge/block/hit animations for every attack direction, and every weapon needs whatever set of those directional attack animations it supports. Nothing crude about it. It's just a lot of work. ;)

    If you want to match the timing perfectly, then you should probably store a bit of data on each attack indicating the "hit" time (in seconds after the animation starts). And on each defense animation, also store how long it takes to get to the block/parry/dodge point (i.e. the point that should match up with the hit). Then you can just do the math to figure out when to start each animation so they both reach that point at the same time. I would do all that in Unity, not in your 3D modeling software (it's easy enough to scrub through an animation in the animation preview window and note the key time).

    Are you using 3D models here, or sprites? In the former case, consider the Animancer plugin. In the latter case, see 2D Animation Methods in Unity. Unity's built-in animation system is, frankly, not all that great.

    Finally, this sounds like a very ambitious first project. Have you considered doing a nice Flappy Bird clone first? :)
     
    TonCoder likes this.
  3. dlich

    dlich

    Joined:
    Apr 21, 2019
    Posts:
    11
    Thx for the answer and sorry for posting in the wrong place. Maybe a moderator can move it to the right forum?

    I guess there are no shortcuts for me, so I'll just have to go through the positions of the characters during animations to match the contact point. Also I've kinda got used to the unity animator and I don't want to complicate my project by also learning how to work with a custom plug in.

    As for the complexity of the project, I am aware that it's better to complete a few smaller games for a beginner, than stalling with a big project, however I just can't force myself to work on something I don't like, especially as a hobby. Not to mention that I've already put quite a lot of effort into this project and I feel it would be a waste to abandon it right now. Also, maybe I didn't learn how to finish a game yet, but I definitely learned a lot more things from this project than I would from a simpler one.

    Anyways, thanks for the answer. I might share my implementation here when I'm done with the system l.
     
    BrandyStarbrite likes this.
  4. FernandoDarci

    FernandoDarci

    Joined:
    Jan 25, 2018
    Posts:
    19
    I don´t know if you already solve your question, but let´s go:

    Many games (almost all I know) uses a single animation for parry or dodge. It´s like a shock between the two characters like both collides against a wall while running. The implementation, in general, is let both frozen from some ticks while the player takes action, so, a "time window".

    So, the best approach for your system is, in my view, let a window between the enemy attack (let´s say, 15 updates) and if the player attacks or defend itself it trigger "parry" (Watching the conditions, like the player will be hit, etc...). The same applies for dodge

    So, it´s Works like:

    * The enemy attacks and the attack will hit the player.
    * Counting the enemy attack window, the player reacts (dodge, attack or defend)
    * If in window time, trigger parry.
    * Change the animations to something fancy.
    * Put some slow motion if cares.
    * Open the new window to player react (that can be 1s)
    * In the window, player wins and enemy is open to be attacked, otherwise, player loses and is open to be attacked.