Unity 2019.3 Script not working!

EDIT: If there was a competition for the stupider person in the world I would have won the first place. The script was returning if the object tag was “Weapon” which shouldn’t. Fixed

I have a script that gives damage to an enemy, the problem is that’s not working anymore.

The script is attached to the player’s weapons, left and right. These weapons can disable/enable themselves based on the enemy position. All my players are prefabs so I can spawn them in the world. Now the problem is that the script doesn’t work even if I try to print something in the console using the update function.

Here is my code:

using UnityEngine;
using Random = UnityEngine.Random;

public class PlayerDamageController : MonoBehaviour
{
    public float maxDamage;
    public float minDamage;
    public float maxExtraDamage;
    public float minExtraDamage;

private void Update()
{
    Debug.Log("Test");
}

    private void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log(this.gameObject.tag);
        if (this.gameObject.CompareTag("Weapon")) return;
        GameObject other = collision.gameObject;
        if (other.CompareTag("Bone") || other.CompareTag("EnemyTarget"))
        {
            float damage = Random.Range(minDamage, maxDamage);

            if (other.name == "Head")
            {
                damage += Random.Range(minExtraDamage, maxExtraDamage);
            }

            if (!other.CompareTag("Weapon"))
            {
                EnemyHealthBar.Instance.DecreaseHealth(damage);
            }
        }
    }
}

I would first comment out this with a vanilla debug.log(“something”)

  • if (this.gameObject.CompareTag(“Weapon”)) return;
  • GameObject other = collision.gameObject;
  • if (other.CompareTag(“Bone”) || other.CompareTag(“EnemyTarget”))
  • {
  • float damage = Random.Range(minDamage, maxDamage);
    • if (other.name == “Head”)
  • {
  • damage += Random.Range(minExtraDamage, maxExtraDamage);
  • }
    • if (!other.CompareTag(“Weapon”))
  • {
  • EnemyHealthBar.Instance.DecreaseHealth(damage);
  • }
  • }

for starters, then I’d go through line by line. also any reason for private methods? Or maybe it is VS injection

It’s Rider injection as I develop on Linux. Also I tried to log but read the edit I’ve made to the post :slight_smile: