Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Question Trouble Detecting Collisions

Discussion in 'Physics' started by mikeymcmanus700, Nov 12, 2023.

  1. mikeymcmanus700

    mikeymcmanus700

    Joined:
    Mar 4, 2023
    Posts:
    10
    upload_2023-11-12_10-54-43.png upload_2023-11-12_10-55-12.png upload_2023-11-12_10-57-8.png During animation, I am setting the weapons collider to active. I am using animate physics in animator for minotaur so the axe collider moves w animation. I am using on trigger enter to try and detect when the axe collides with the knights capsule collider. I cannot register this collision/trigger enter for the life of me. I want to have the weapon pass through the players not react with physics so anyway that anyone could help me through this problem would be appreciated very much! If there is any other detail needed please let me know.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class EnemyMeleeWeaponDealDamage : MonoBehaviour
    6. {
    7.     float damageAmount = 10f;
    8.     public bool isBlocked;
    9.  
    10.     private void OnTriggerEnter(Collider other)
    11.     {
    12.         if(other.CompareTag("AllyBasic"))
    13.         {
    14.             DealDamageToNPC(other);
    15.             Debug.Log("hit");
    16.         }
    17.     }
     
  2. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    You have the mesh collider of the weapon set to isTrigger = false and the main capsule collider set to isTrigger = true. Shouldn't that be the other way round?
     
  3. mikeymcmanus700

    mikeymcmanus700

    Joined:
    Mar 4, 2023
    Posts:
    10
    I did try to switch both but neither worked