Search Unity

Question Enemy taking double damage after the first hit

Discussion in 'Scripting' started by matthewcooper, May 26, 2020.

  1. matthewcooper

    matthewcooper

    Joined:
    Apr 25, 2019
    Posts:
    40
    Could someone help me with this? The first attack does 5 damage which is the correct amount and then every attack after that does 10 damage, it's doubling whatever I set the attack value as for any attack after the first, I have debugged it and I'll include that screenshot below.

    These are the scripts: https://pastebin.com/0mCAkSzh

    https://pastebin.com/5SV4tPNA

    I'm posting pastebins because one of the scripts is quite long.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    How to report problems correctly in the Unity3D forums:

    http://plbm.com/?p=220

    This is not fixed by posting to pastebin. Instead, put instrumentation into your code to identify more exactly where things are going wrong so that you can post precisely the right piece of relevant code. To this end, I recommend adding extensive Debug.Log() calls.

    In any case, at a minimum you should be able to identify which is happening:

    1. the enemy is receiving damage on two separate occasions

    2. the enemy is receiving one piece of damage that is twice as large

    Figure that out and you'll be most of the way to fixing it. Nobody here can tell you which of #1 or #2 above is happening.