Hey all,
This might be a really simple error, but I can’t seem to solve it.
var distun = Vector3.Distance(Target.transform.position, transform.position);
if (distun < 1.5){
MeleeAttack(Target);
}
So what this does is initiates an attack with the Target (assigned in the inspector as Player Game Object) if they get closer than 1.5 unity meters.
But, I get two errors:
#1- An instance of type ‘UnityEngine.Component’ is required to access non static member ‘transform’.
#2- The best overload for the method ‘zombie_main.MeleeAttack(UnityEngine.Transform)’ is not compatible with the argument list ‘(System.Type)’.
The first error occurs on the first line, and the second error occurs on the third line.
Any suggestions on how to fix this?