edited October 2022 in ORK Scripting
How does one access position 1 in the player group?
I'm using a deprecated camera asset that I love adore however for it to auto set to a player I need to assign a tag.
Shame this asset got deprecated but this is the tutorial I wrote years back so you can see what the editor looks like:
https://forum.orkframework.com/discussion/3559/tutorial-simple-rpg-camera-setup#latest

I'm happy to modify tags in runtime that's not an issue, that's easy.

What I need help with is accessing the prefab assigned to the Leader position in the player group. As this can be changed with character swapping, I didn't wanna just manually assign it. I know I can access Ork Combatant list via editor list
Combatant combatant = ORK.Game.Combatants.Get(index); [at least this was how it was in Ork2]

But I'm interested in the players active group.

GamingIsLove.ORKFramework.PlayerChanged
GamingIsLove.ORKFramework.CombatantGroup
GamingIsLove.ORKFramework.GroupLeaderSorter

At a loss how to proceed.
At its core what I want is simple. Update my camera to always be targetting the Field Leader.

When party list or position is changed assign the new leader the Camera target tag, then switch off the others in the party.
Then update the camera script object (which is also easy to do, I know how to do that), so I can have it target whoever is in the lead position.
I'm fairly certain this is possible given how formation work. the leaders position must be tracked somewhere right?

Post edited by paulgswanson on
  • edited October 2022

    But I don't know how to have that feed my script when it gets called. is this what I should be looking for?

    In that case I think group 0 is the player faction? (after further investigation, Group 0 is definitely the player faction)

    Iv got this so far, I just don't know how to access that info yet:

    using GamingIsLove.ORKFramework;
    using System.Collections.Generic;
    using System.Collections;
    using Lovatto.MiniMap;
    using UnityEngine;
    using PhatRobit;

    public class pgs_CharacterTrackers: MonoBehaviour
    {
    SimpleRpgCamera RPGCam;
    bl_MiniMap RPGMiniMap;
    public GameObject Leader;
    public Transform Target;
    public string LeaderName;
    public string LeaderNameMap;
    public bool isMapConfig;
    public bool isCameraConfig;

    // Start is called before the first frame update
    void Start()
    { }

    // Update is called once per frame
    void Update()
    {
    if (isCameraConfig) { SetupCamera(); }
    if (isMapConfig) {SetupMap(); }
    }

    void GetOrkData()
    {
    if (ORK.Game.ActiveGroup.FieldLeader != null)
    { Leader = ORK.Game.ActiveGroup.FieldLeader.GameObject;
    Target = ORK.Game.ActiveGroup.FieldLeader.GameObject.transform;
    GameObject.Find(LeaderName);
    LeaderName = Leader.name;
    LeaderNameMap = Leader.name+"/Root";
    }
    }

    void SetupCamera()
    {
    RPGCam = gameObject.GetComponent<SimpleRpgCamera>();
    GetOrkData();
    if (Leader != null) { RPGCam.target = Target; }
    else
    GetOrkData();
    }

    void SetupMap()
    {

    }
    }
    Post edited by paulgswanson on
  • edited October 2022
    Ok so I give up.
    Iv discovered after running thru the api quite extensively at this point that
    there is a IsLeader bool
    Group group is a direct reflection of the index in the editor and default player group is 0
    and that the Combatant can be access by CombatantSetting.CombatantPrefab
    also that I can manually tell it to set a leader...(not the goal of course)

    public override void GamingIsLove.ORKFramework.GroupAccessHandler.SetLeader ( Group group, Combatant newLeader, bool moveOldBack)

    But I just cannot figure out how to actively tell my above script who the Field Leader presently is. So I give up for the night. Hoping you can help me out GiL
    Post edited by paulgswanson on
  • edited October 2022
    This gives you access to the current player group:
    ORK.Game.ActiveGroup

    This accesses the leader combatant (field leader out of battle, battle leader in battle):
    ORK.Game.ActiveGroup.Leader

    There are also separate versions for FieldLeader and BattleLeader to get them specifically.

    So, to get the game object of the field leader, you'd use:
    ORK.Game.ActiveGroup.FieldLeader.GameObject

    I'd recommend first checking if the leader exists, though:
    if(ORK.Game.ActiveGroup.FieldLeader != null)
    Otherwise you might call it before the leader is added at the start of your game and run into an error :)


    That's btw the same as in ORK 2 - ORK.Game.Combatants.Get(index); doesn't give you the player, just the first combatant that was registered in the scene (though that'll in most times be the player).
    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 October 2022
    Thx GiL! Worked perfectly!
    Updating my intial script.

    I was able to entirely eliminate the tags idea with that.
    Post edited by paulgswanson on
Sign In or Register to comment.