Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Animator problem Unity

Discussion in 'Animation' started by efe99912, May 30, 2023.

  1. efe99912

    efe99912

    Joined:
    Mar 20, 2023
    Posts:
    1
    Hello, I wish you good work. I have a problem related to Unity's animator part. As seen in the video in the link I posted, the characters initially perform their normal running animation movements, but then they fall. What is the reason of this? I am using the raycast method for the enemy ai that if they see the player clear distance they start running towards him.



    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.AI;
    5.  
    6.  
    7. public class DüşmanAI : MonoBehaviour
    8. {
    9.     public NavMeshAgent enemy;
    10.     public GameObject player;
    11.     Animator animator;
    12.     float distance = 100f;
    13.    
    14.     public LayerMask hedef;
    15.  
    16.     Ray ray;
    17.     RaycastHit hit;
    18.     // Start is called before the first frame update
    19.     void Start()
    20.     {
    21.         animator= GetComponent<Animator>();
    22.     }
    23.     void check()
    24.     {
    25.         if (Physics.Raycast(transform.position, transform.forward, out  hit, distance) )
    26.         {
    27.  
    28.            
    29.  
    30.         }
    31.        
    32.        
    33.        
    34.     }
    35.  
    36.     // Update is called once per frame
    37.     void Update()
    38.     {
    39.         enemy.SetDestination(player.transform.position);
    40.         animator.SetBool("koşma", true);
    41.         //check();
    42.  
    43.     }
    44. }
    45.