edited March 2014 in ORK Scripting
I'm making a 2D game with custom controls and I know about adding new behaviors in the game controls menu to allow me to do this. I was wondering if there is a way to make it so my speed variables in my custom script can be controlled by adjusting the speed settings in the ORK framework editor?
Post edited by gamingislove on
  • edited March 2014
    If you're referring to the combatant's speed settings - you can do this by getting your game object's combatant.

    You can get the combatant through the CombatantComponent, which attached to every combatant in your scene. There's a helper class to easily get it:

    Combatant combatant = ComponentHelper.GetCombatant(this.gameObject);

    After that, you can access the combatant's speed through:

    float speed = combatant.GetMoveSpeed(MoveSpeedType.Run);

    Edit: moved to scripting.
    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!
  • Ok cool. Well I tried accessing the combatant component and couldn't get it to find it. I think I have everything set up right in my code. Does my script need to be in a special folder or something? Sorry, I'm an artist that dabbles in scripting from time to time. Plus I normally use Javascript and am trying to move over to C#.

    Anyway, this is my code that I plugged in to behaviours for game movement for testing.

    using ORKFramework;
    using UnityEngine;
    using System.Collections;

    namespace ORKFramework.Behaviours
    {
    public class PlayerControlSprites : MonoBehaviour
    {
    private Combatant combatant = null;

    void Start ()
    {
    combatant = ComponentHelper.GetCombatant(this.gameObject);
    }

    void Update ()
    {
    if (combatant != null)
    {
    Debug.Log("Found");
    }
    else
    {
    Debug.Log("Null");
    combatant = ComponentHelper.GetCombatant(this.gameObject);
    }
    }
    }
    }
  • Check your combatant's game object if there even is a CombatantComponent attached to it ...
    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!
  • Yep, it gets added when spawning, and the control script is there as well...
  • Just gave it a try with your code and it's working for me (I get the console spammed with 'Found').

    It doesn't matter if the component is already added to the prefab or added by ORK (through custom control behaviours). Also, it works with and without the namespace, and when it's compiled within the DLL or as an additional script in Unity - all versions work for me ...
    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!
  • Hmmm, okay, i'll give it another go. Thanks for confirming that the code should be working.
  • Yeah, tried it on the game tutorial project and it works fine. I must have something set up wrong.
  • Alright, got speed and everything working with the ORK framework editor. Started a new project and worked fine. Must have messed something up while experimenting late at night. heh

    Thanks for the help!
Sign In or Register to comment.