edited September 2018 in ORK Scripting
For example I'm trying to access my Player combatant HP value from a C# script. I have no idea where to even start.

EDIT: Nevermind. I found my problem: I didn't actually assign my player to the variable.


ysabod = GameObject.FindGameObjectWithTag("Player");
ysacom = ComponentHelper.GetCombatant(ysabod);


That did it.
Post edited by Creiz on
  • There's an even easier way to get the player game object or combatant without using the find function from Unity (which can be quite slow when used often).

    This returns the player's game object:
    GameObject playerObject = ORK.Game.GetPlayer();
    This returns the player combatant:
    Combatant playerCombatant = ORK.Game.ActiveGroup.Leader;
    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!

  • using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using ORKFramework;
    using ORKFramework.Behaviours;

    public class MuscleControl : MonoBehaviour {
    public int blendCount;
    public GameObject ysabod;
    public SkinnedMeshRenderer blendg;
    public Combatant ysacom;

    // Use this for initialization
    void Start () {
    ysabod = GameObject.FindGameObjectWithTag("Player");
    ysacom = ComponentHelper.GetCombatant(ysabod);
    blendg = this.GetComponent<SkinnedMeshRenderer>();



    if (blendCount <= 0)
    {
    blendCount = 0;
    }
    }
    private void Update()
    {
    blendCount = ysacom.Status[13].GetValue();
    Debug.Log(blendCount);
    blendg.SetBlendShapeWeight(0, blendCount);
    }

    public void increaseBlend()
    {
    blendCount += 10;


    }
    public void decreaseBlend()
    {
    blendCount -= 10;

    }
    }


    So this is my whole code. It worked perfectly yesterday. No problems. Today, magically, I'm having an "object reference not set to an object" error on "blendCount = ysacom.Status[13].GetVaalaue();" and nothing works anymore.

    Oh my god coding is hard.
  • edited September 2018
    That's most likely due to the player not being spawned (or not having the Player tag) when the component is initialized.

    E.g. remove finding the player from the start function and directly access ORK's player combatant:
    private void Update()
    {
    if(ORK.Game.ActiveGroup.Leader != null)
    {
    blendCount = ORK.Game.ActiveGroup.Leader.Status[13].GetValue();
    Debug.Log(blendCount);
    blendg.SetBlendShapeWeight(0, blendCount);
    }
    }
    Post edited by gamingislove on
    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!
  • Thank you so much for your help, GIL.

    By the way, in the combat scenes, whenever an enemy attacks my player, the player gets stuck in the enemy's spot until I attack again, which then the player plays it's animation then goes back to it's spot. Do you have an idea on how to fix this?
  • edited September 2018
    Sound like you're moving the player instead of the enemy in the enemy's attack - the player would be the Target actor, the enemy the User during an enemy's attack. This is handled in the battle events used to animate the attack ability.
    Post edited by gamingislove on
    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 September 2018
    Thank you, GIL. I managed to fix it: it wasn't a problem with the scripts, actually. I'm using the ones you provided in your demo, along with following the tutorial on different scene battles. Which brings us to my next (and hopefully last, because everything works correctly it's only the battle system that is causing me some trouble). Converting all animations to Mecanim solved the issue.

    In my battle scene, I have a Game Object with a Battle Component. This BC is setup just like your Nearest Battle tutorial. Everything else works okay, when I get near the monster, the battle starts(I wish it would start when I get a bit nearer, or when I touch it but the monster will not spawn unless I set the Combatant Spawner to Autostart, but that is another problem for another day: I'm still toying with the options), The combat starts, attacks are now working correctly and everybody goes back to their place when they're done. That's great.

    The problem I'm having now is that the characters always rotate away whenever a new action is made. Here, take a look at this video( https://my.mixtape.moe/fddods.webm ), you'll see what I'm talking about. You can also observe how they don't move next to each other when they attack, they stop near the center.
    Post edited by Creiz on
  • I think you're moving back to base without looking back at the enemy - try enabling Reset Look Angles in the last battle event of the attack (Event Settings node).
    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!
Sign In or Register to comment.