Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Trigger a function only when a certain event happens

Discussion in 'Scripting' started by S4MA3L, Jul 28, 2020.

  1. S4MA3L

    S4MA3L

    Joined:
    Apr 17, 2020
    Posts:
    32
    I am trying to develop a unity pun2 multiplayer, and I have a problem with applying damage when a projectile explodes in range of the player. So my question is.. All network stuff apart.

    How can I trigger a function inside my player GameObject when the explode function inside my throwable projectile GameObject is triggered? These are separate gameobjects.
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,013
    You could Spherecast and check for any players within it and call the method on the ones that are.
     
  3. S4MA3L

    S4MA3L

    Joined:
    Apr 17, 2020
    Posts:
    32
    I already thought of that. But I set a timer for the throwable projectile for explosion. I only want this script to be called when the explosion happens after the fixed time. That's what confuses me.
     
  4. ItzChris92

    ItzChris92

    Joined:
    Apr 26, 2017
    Posts:
    365
    If you already have the timer then just do as the above post mentioned once the timer has elapsed.
     
unityunity