edited March 2014 in ORK Support
I'm wondering if it is possible to create a combatant through script?
I'm just playing around and experimenting. I decided to try this.
I was able to add a CombatantComponent. But, the combatant (most important part) was null.

With that, I wasn't able to continue with my experimenting :)

Forgot to add:
I did the following with the COMBATANT of the CombatantComponent

cc.combatant = new Combatant();

That gave me access to the combatant class. However, ORK was trying to fire off its TICK event. (I have not added an ORK start event or anything like that yet).
Post edited by keyboardcowboy on
  • Sure you can:

    Combatant combatant = ORK.Combatants.Create(int index, Group group);

    This creates a base initialized combatant of ID index and adds it to the specified group (if you use null, a new group will be created.

    Once you get your base initialized combatant, you have to initialize him for the game:

    combatant.Init();

    This will initialize the combatant with the start level and class defined in the combatant's settings. Alternatively, you can also use the following code to initialize to a specific level and class:

    combatant.Init(int level, int classLevel, int classID);

    Now, you can spawn the combatant in the scene using:

    combatant.Spawn(Vector3 position, bool setRotation, float yRotation, bool setScale, Vector3 scale);

    You'll need to set the position where you want to spawn him, setting the y-rotation and scale is optional (but you'll still need to define the parameters.

    So, in total, an example could look like this (position is the position to spawn at):

    Combatant combatant = ORK.Combatants.Create(0, null);
    combatant.Init();
    combatant.Spawn(position, false, 0, false, Vector3.one);
    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 March 2014
    Haven't dug that deep into the ORK namespace yet :)
    Thanks for that little "tutorial".

    I tried your little tutorial out.
    It ran fine for the first time. After that, each time I run it (after I stop the player in the editor and start it up again), I get the following error:

    NullreferenceException: Object Reference not set
    ORKFramework.ORK.get_Combatants()


    Any ideas on that one? I didn't do the spawn. Just this:


    if(GUI.Button(...))
    {
    Combatant c = ORK.Combatants.Create(0,null);
    c.Init();
    c.SetName("BOB");
    Debug.Log(c.GetName());
    }


    Like I said initially, I'm just playing around seeing what I can do in code with ORK.
    Post edited by keyboardcowboy on
  • Did you add the ORK Game Starter object to that scene (or, go through a main menu which had the ORK Game Starter)?
  • I just keep playing...I added a game starter to the scene and the error went away :)
  • Check out this how-to on quick game testing with game starters - it doesn't hurt having one of them in each scene :)
    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.