edited February 2021 in ORK Support
In the battle start event i would like to run a function from a component attached to the prefab of all combatants. Kindly guide me on how to proceed.

I also want to run a function from a component attached to the prefab when i use any ability (attack, magic, cast, item etc). I want to send the target position so i can move the player to it. I know i can just use events to move the player but i want to do it through the script.

EDIT - i did try searching the forums but no matter what keywords i use the search results are no where close to what i need.
Post edited by BadlySynced on
  • There are the function nodes for this, e.g. Call Function. The combatants participating in battle are available as the actors in the battle start event, e.g. Player Group actor for all player combatants. In battle events of your abilities, the combatants are user and target actors.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited February 2021
    How would i print values like number of combatants/allies/enemies using the base>debug?

    And Call Function doesnt work for me or i dont understand how to use it
    image

    In this battle start event, i am first printing Start Battle to confirm that the event is running.
    Then in Call Function i have set Class Name as CombatAnimations which is the class/script name attached to the root of the combatant. Function name is SetupCombatPosition, it is public, returns void and has no parameter. That method also has a debug print to check if it worked. That function is never called.
    I have one combatant in player group and one in enemy. i tried using both groups in Call Function but it doesnt work.
    Post edited by BadlySynced on
  • You'd first have to store them into variables and use the variable text codes to show them. Though, if you just want to see the stats of a combatant, you can do that via the inspector of the combatant's game object.

    Based on the info I'd say it should work. Are you using the combatant's Child as Root setting by any chance?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited February 2021
    EDIT - I FIGURED IT OUT, IT WAS MY MISTAKE
    For others if they see this, i made 2 mistakes
    1. My way of storing the variable was wrong, in the image you can see that i was using a variable name to set the variable name, instead just enter whatever you want in the variable key text area.
    2. in the store combatant count node i had selected the actor as enemy group, so now the player count is printed if i print enemy count as the player is the enemy of the enemy group.

    ----------------------------------------------------------------
    Based on the info I'd say it should work. Are you using the combatant's Child as Root setting by any chance?
    No, i am not.

    Its a turn based battle that starts when entering the Battle Sphere Collider.
    I have 3 enemies in that battle, all same combatants.
    image
    The enemies do spawn in game and i can see 3 prefabs.

    Then in the battle start even i use the Store Combatant Count into a variable, i use Enemy Group as the Actor. I use Local as Variable Origin.

    image

    I then use debug to print the value of that local variable.

    image

    But the value in the log is printed "Number Of Enemies : 0"
    Post edited by BadlySynced on
  • edited February 2021
    EDIT - I FIGURED IT OUT, IT WAS MY MISTAKE, check previous comment for explanation

    I added Init and Spawn events to the combatant and added base>debug to them and the order of execution now is:
    1. Init combatant (3 times as i have 3 combatants in the enemy group)
    2. Battle start event
    3. print number of enemy combatants (prints 0)
    4. Spawn combatants (3 times)

    i then added the Spawn Combatants node in the battle start event before the base>debug (where i print number of combatants) node.
    Then the order of execution becomes:
    1. Init combatant (3 times as i have 3 combatants in the enemy group)
    2. Battle start event
    3. Spawn combatants (3 times)
    4. print number of enemy combatants (still prints 0)
    Post edited by BadlySynced on
  • edited February 2021
    Figured out the debug issue, but Call Function is still not working for me.

    EDIT- restarting Unity fixed it. no changes were made to the event or scipts.
    Post edited by BadlySynced on
  • So, all solved for now?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • So, all solved for now?
    Yes, thanks
Sign In or Register to comment.