Search Unity

Question Weapon Shoot Trigger

Discussion in 'Visual Scripting' started by HAMSOFT, Jan 24, 2023.

  1. HAMSOFT

    HAMSOFT

    Joined:
    May 31, 2020
    Posts:
    32
    Hii.

    How can I make that my weapon shoot function triggers?
    This is the weapon script:

    This is the enemy script that should shoot the function:



     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,079
    As long as both the Custom Event and Custom Event Trigger reference the same GameObject, it'll trigger. Your enemy script tries to trigger Shoot custom event on "weapon" Object variable. Is your weapon graph also on "weapon" variable's GameObject?
     
    HAMSOFT likes this.
  3. HAMSOFT

    HAMSOFT

    Joined:
    May 31, 2020
    Posts:
    32
    Yes it is
     
  4. HAMSOFT

    HAMSOFT

    Joined:
    May 31, 2020
    Posts:
    32
  5. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,079
    Are you trying to reference a prefab from Project Window? If so, that won't work since prefabs are like templates that don't exist in scene unless added to Hierarchy. You need to reference GameObjects from Hierarchy.
     
  6. HAMSOFT

    HAMSOFT

    Joined:
    May 31, 2020
    Posts:
    32
    Really? I didn't know it. I will try to change it to the one on the Hierarchy
     
  7. HAMSOFT

    HAMSOFT

    Joined:
    May 31, 2020
    Posts:
    32
    It actually worked