My Raycast is working and hitting my Enemy.
But if I hit him, I want to change the health variable in the other script of the hit Object (Enemy Controller) by calling the TakeDamage(damage)
function.
Unfortunately, I get this error:
"Assets/Weapons/FPS Weapons/Scripts/Gun_Controller.js(692,35): BCE0018: The name 'EnemyController' does not denote a valid type ('not found'). Did you mean 'System.ComponentModel.EnumConverter'?"
Here's my Code:
if (hit.transform.tag == "warzombie_01") {
// Impact Particle for Enemy - warzombie_01
var impactHitBlood: GameObject = Instantiate(impactEffectBlood, hit.point, Quaternion.LookRotation(hit.normal));
Destroy(impactHitBlood, 0.5 f);
//var enemyController : EnemyController = hit.transform.gameObject.GetComponent.<EnemyController>();
var enemyController: EnemyController = hit.transform.GetComponent(EnemyController);
if (enemyController != null) {
enemyController.TakeDamage(damage);
}
}
Thanks!