Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

Feedback Killed by last collision

Discussion in 'Scripting' started by TiToMoskito, May 1, 2021.

  1. TiToMoskito


    Jan 28, 2014
    Hi i have a question.
    I want to implement an kind of collision detection for my players, to see who killed the player by the last contact which directed him to death.
    There are two scenarios how a player can die in my game.
    1. Health <= 0
    2. Falls into water

    This is my code currently:
    But im not very happy with it, because when i hit a player XY, walk around for about 2 minutes and die, than player XY "has killed me", but i died because i jumped into the water.
  2. GroZZleR


    Feb 1, 2015
    Filter your damage through a TakeDamage function on your player that also needs an owner or source parameter. Then you can remove the LastHit logic because it's built-in to your damage.
    Kurt-Dekker likes this.