hello i am making a 2d game and i made a health script for my game. i do not know how to code and i followed brackeyes tutorial. I just want replace the “if touch space then loose health” to something like “if touch collider2d with tag (tag) then loose health”. Code for the health here :
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
Plug one in, iterate all the InputManager’s keys, display them, and see which one moves.
That’s all I would do. If you read on the net that it is “XYZ” and you code up that and it doesn’t work, you’re going to go back to the above in any case. Just do it now, save a lot of time.
make sure the stuff your triggering has a rigid-body and whether or not it moves use kinematic and set colliders to trigger (or not depends on what is happening).
The other gameObject needs the tag “Enemy” to work.
The part i comment out you can use if the enemy should take the damage and he has a ApplyDamage method.
Hi, I am creating a top down game, i used the same code and is working perfectly fine, the problems come when, I hit an enemy, I take one damage, but then, if I stay steel, I will not suffer more damage, I was trying to give invulnerabilities frames or knockback, but couldnt find any code, can someone help please.