- Home /
 
 
               Question by 
               RoyalScape · Jul 14, 2017 at 07:32 PM · 
                movementenemyaihand  
              
 
              How to bring a character's hand to a given position (IK) C#
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.
I created states and found the player position please tell me so that i can bring monster hand to that player position where my player was.C#
public enum State { Idle, Attack, Investigate }
 //public GameObject target;
 public State state;
 private bool alive;
 Transform playerTransform;
 // 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");
     GetPlayerTransform();
     //target = GameObject.FindWithTag("Player").transform;
 }
 void GetPlayerTransform()
 {
     GameObject go = GameObject.FindWithTag("Player");
     if (go != null)
     {
         playerTransform = go.transform;
         Debug.Log("player found");
         //transform.LookAt(playerTransform);
     }
     else
     {
         Debug.Log("player not found");
     }
 }
     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;
     }
 }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Issues with Character Controller moving Enemies 1 Answer
Moving from point A to point B to point A to point B over and over 1 Answer
AI code for enemy car to follow the player car 0 Answers
Editor movement suddenly became very slow 2 Answers
Oculus Quest player controller not moving on the vertical axis when using New Vector3 script 0 Answers