So I have ray shoting out but script is not working .
using UnityEngine;
using System.Collections;
public class RAY : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton (0)) {
RayClick ();
}
}
void RayClick()
{
RaycastHit hit = new RaycastHit ();
if (Physics.Raycast (transform.position, transform.forward, out hit)) {
actorenemymanager rc = hit.transform.GetComponent<actorenemymanager>();
if (rc != null)
rc.damage (50);
}
}
}
Is on player thats shoting and
using UnityEngine;
using System.Collections;
public class actorenemymanager : MonoBehaviour {
public float health = 150;
void Start () {
}
// Update is called once per frame
void Update () {
}
public void damage(float damagerecived){
health -= damagerecived;
if (health < 0) {
Destroy (gameObject);
}
}
}
is on the enemy , in console it detects that its hiting enemy but no health arent reduced .