**I keep getting this error**- Assets/Fighter.cs(29,63): error CS1061: Type `Mob[]' does not contain a definition for `getHit' and no extension method `getHit' of type `Mob[]' could be found (are you missing a using directive or an assembly reference?)
using UnityEngine;
using System.Collections;
public class Mob : MonoBehaviour { public float speed; public float range; public CharacterController controller; public AnimationClip run; public AnimationClip idle;
public Transform player;
private int Health;
// Use this for initialization void Start () { Health = 100; } // Update is called once per frame void Update () { if (!inRange ()) { Chase (); } else { animation.CrossFade(idle.name);
} }
bool inRange () { if(Vector3.Distance(transform.position, player.position)< range) {
return true; } else {
return false;
} }
public void getHit(int damage)
{ Health = Health - damage;
} void Chase() {
transform.LookAt (player.position);
controller.SimpleMove (transform.forward * speed);
animation.CrossFade (run.name);
} void OnMouseOver()
{ player.GetComponent ().opponent = gameobject; } }
↧