Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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.