I want to make a Big Monster that spots the player last position and at that last position Monster Hit his Hand at that players last know position. Please Help me with the scripting part tell me how can i do it and please provide me a sample of script C#.
Big Monster just stand and looks if he spots player monster only move his hand and hit his hand at that specific position only and then repeat to spot player.
public enum State
{
Idle,
Attack,
Investigate
}
public GameObject target;
public State state;
private bool alive;
// Variables for Investigate
// Variable for Idle
// Variable for Attack
// Use this for initialization
void Start ()
{
state = EBasicAI.State.Investigate;
alive = true;
StartCoroutine("FSM");
}
// Update is called once per frame
void Update () {
}
IEnumerator FSM()
{
while (alive)
{
switch (state)
{
case State.Investigate:
Investigate();
break;
case State.Attack:
Attack();
break;
}
yield return null;
}
}
void Investigate()
{
Debug.Log("Investigate");
}
void Attack()
{
Debug.Log("Attacking");
}
void OnTriggerEnter(Collider coll)
{
if (coll.tag == "Player")
{
state = EBasicAI.State.Attack;
target = coll.gameObject;
}
//else
//{
// state = EBasicAI.State.Investigate;
// }
}
void OnTriggerExit(Collider coll)
{
if(coll.tag == "Player")
{
state = EBasicAI.State.Investigate;
}
}
I Created the states but how enemy find player last position and Hit his hand to that know position that i want please help me!!