Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Bug The Slime Critter attack throws the player several meters away

Discussion in 'Open Projects' started by Eddrico, Feb 3, 2021.

  1. Eddrico

    Eddrico

    Joined:
    Jan 29, 2021
    Posts:
    10
    Short description
    When the slime critter attacks and the player jumps, the inertia of the attack is transferred to the player, throwing the player several meters away.

    Expected behavior
    The attack should not push the player so far.

    To Reproduce
    Steps to reproduce the behavior:
    1. Open a scene with the TestingGround. Press play.
    2. Get near a Slime Critter and wait for his attack.
    3. When the attack is about to connect, press the jump button.
    4. Observe that the player is sent flying away.
    Notes
    • Here's a video of the issue:


    Ps.- Again, not sure if this is the right way to report a bug.
     
  2. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    742
    Hey, thanks for reporting it. Can you put it on the repository? (do you have a Github account?)
    Thanks again, QA is important too!!
     
  3. Eddrico

    Eddrico

    Joined:
    Jan 29, 2021
    Posts:
    10
    As a new issue right? done

    yes

    I was actually trying to identify the terrain with a raycast and i got stuck in the rocks, an accidental finding
     
  4. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    742
  5. Ehsan_74

    Ehsan_74

    Joined:
    May 20, 2016
    Posts:
    2
    Hi, I want to work on this bug, it is my first time to participate in an open project.I am so excited. I hope we can fix it.:);)
    It looks it is an important bug so i am on it, i hope i can do something.:oops:
    After finding the cause of the bug, i post my solution here.
     
    Last edited: Feb 22, 2021
    cirocontinisio likes this.
  6. asb9599

    asb9599

    Joined:
    Oct 22, 2017
    Posts:
    3
    Hi there! I posted this on the Discord, but I took a stab at this issue as well as another related one (#383) as part of a homework assignment I have for a course I'm taking. As far as the cause of the bug, it appears to be primarily due to the collider of the player and Slime being stuck inside each other after the hit logic is completed, which causes the player to be pushed back excessively. As far as the solution goes, I found that simply stopping the Slime after it successfully hit the player worked very well as an easy fix. However, I did end up adding a UnityEvent to the Attack class for ease of access to the Slime's particular attack logic during OnTriggerEnter, so I was not sure if this would be frowned upon by the community.
    Code (CSharp):
    1.     private void OnTriggerEnter(Collider other)
    2.     {
    3.         // Avoid friendly fire!
    4.         if (!other.CompareTag(gameObject.tag))
    5.         {
    6.             if (other.TryGetComponent(out Damageable damageableComp))
    7.             {
    8.                 if (!damageableComp.GetHit)
    9.                 {
    10.                     damageableComp.ReceiveAnAttack(_attackConfigSO.AttackStrength);
    11.                     // Invoke any necessary hit events
    12.                     onHit?.Invoke();
    13.                 }
    14.             }
    15.         }
    16.     }
    I also added a StopAttack() method to the SlimeCritterAttackController class that simply resets the timer used to update position in the target vector, so I simply hooked up that to the successful hit event and it appears to work properly now. Might need a bit more testing, but, given the damage logic of the game as it is right now I think that simply stopping the Slime after it hits the player is a good temporary solution.
     
unityunity