i get this error Assets/myscripts/Mob.cs(62,57): error CS0118: Mob.opponent' is a
field’ but a `type’ was expected here is my code
using UnityEngine;
using System.Collections;
public class Mob : MonoBehaviour
{
public float speed;
public float range;
public CharacterController controller;
public Transform player;
private Fighter opponent;
public AnimationClip run;
public AnimationClip idle;
public AnimationClip die;
public AnimationClip attackClip;
public double impactTime = 0.36;
public int health;
public int damage;
private bool impacted;
// Use this for initialization
void Start ()
{
opponent = player.GetComponent<Fighter> ();
}
// Update is called once per frame
void Update ()
{
Debug.Log (health);
if(!isDead ())
{
if(!inRange ())
{
chase ();
}
else
{
animation.Play(attackClip.name);
}
}
else
{
dieMethod();
}
}
void attack()
{
if(animation[attackClip.name].time>animation[attackClip.name].length*impactTime&&!impacted)
{
opponent.getHit
impacted = true;
}
}
bool inRange()
{
if(Vector3.Distance(transform.position, player.position)<range)
{
return true;
}
else
{
return false;
}
}
public void getHit(int damage)
{
health = health - damage;
if(health<0)
{
health = 0;
}
}
void chase()
{
transform.LookAt(player.position);
controller.SimpleMove(transform.forward*speed);
animation.Play(run.name);
}
void dieMethod()
{
animation.Play(die.name);
if(animation[die.name].time>animation[die.name].length*0.9)
{
Destroy(gameObject);
}
}
bool isDead()
{
if(health <= 0)
{
return true;
}
else
{
return false;
}
}
void OnMouseOver()
{
player.GetComponent<Fighter>().opponent = gameObject;
}
}