edited April 2015 in ORK Scripting
been trying to figure out how to pull the icon for equipped items from script so i can store them in a script like i do with my other vars. but i cant seem to find what im looking for.
after getting the component im using the following to pull info from the


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

public class getequipmenticons : MonoBehaviour {
public Texture2D icon1;
public Texture2D icon2;



// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
CombatantComponent combatantComponent = gameObject.
GetComponent<CombatantComponent> ();
if (combatantComponent != null) {
Combatant combatant = combatantComponent.combatant;
icon1 = combatant.Equipment[0]getequipmenticons();
}
}
}


but it dont do nothing. dont need any of the other info just the the icon it self so i can stick it into the hud im creating. so if i can get some help with this code that be great thanks!
Post edited by wtyson on
new website can be found here http://www.fore-loregames.com

Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

or check out the face book page here https://www.facebook.com/ForeLoreGames
  • combatant.Equipment[0] will only get you the equipment slot, not the actual equipment that's equipped there. You should first check if something is equipped:

    if(combatant.Equipment[0].Equipped && combatant.Equipment[0].Equipment != null)

    To get the item, use this function:

    Texture2D icon = combatant.Equipment[0].Equipment.GetIcon();
    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 April 2015
    if i wanted to get the wep slot say for the right hand i have mine at 4 in the equipment parts my code should look like this when checking?

    if(combatant.Equipment[4].Equipped && combatant.Equipment[4].Equipment != null)

    so after i check to make sure something is equipped the other code snip will pull the icon off the equipped item? icon = combatant.Equipment[4].Equipment.GetIcon();

    just making sure im understanding this correctly.
    Post edited by wtyson on
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • Yes, that's correct.
    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!
  • i have one more question on this my wep is id 0 the equipart is id 4 fromt he code i posted above should i be changing anything? cause as of now its not picking anything up an i have everything set to be equiped on start
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • nvm got it working thanks
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
Sign In or Register to comment.