Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Final IK - Working on custom actions for manipulating the FBBIK component

Hey there,

I've been working to create custom actions that allow for direct access to the FBBIK component through Adventure Creator. So far I've developed one for the Body and another for Limbs. As I am not a coder, I've pulled these scripts together by utilizing existing action scripts within AC and using coding from the Final IK integration scripts for Playmaker and Rewired to adapt them. 

I haven't tested them exhaustively or anything but they appear to actually work. However, I'm looking for any advice anyone might have on adding an interpolation or transition time to the change in values. Maybe it isn't meant to work that way, but I thought I'd ask. Thoughts?

I have a few more Final IK actions I'm working on. Right now I'm finishing a custom action for Resume Interaction, which is pretty straightforward and works nicely in an action list with the custom action on the wiki submitted by Snebjorn and PurpleShine -- (i.e. if you want to add actions while the interaction is paused and then resume after). If there's interest, I'm happy to share.


  • edited September 2016
    Great! More fine work! :D I'll be taking a look at these later. Hopefully I'll use them this year too :) (my current project doesn't use humanoids though, so it'll be for the next one). About the transitioning, this sounds like a job for lerping. You can find more about it here and here. I haven't had the need to use it much yet, though, but I think you should try putting all the lerping operations in the same coroutine and see what happens (AC actions can work as a coroutine too, so that'll be handy), if that doesn't work put the lerping operations into separate coroutines(I guess? lol). Edit: You can also check Smoothstep and SmoothDamp if you feel there's a need for smoothing the transition. There's also an example of using a coroutine to lerp in here.

    Anyway, If you don't mind it'd be great if we can put these in the wikia too :) It'd also be great to see your other integration actions, heh
  • Thank you so much for all of the links! I am slowly learning but some of this stuff still makes my head explode. I'll post the other interaction action tomorrow. Take care!
  • Hey, don't worry. I'm in the same boat, I've been programming only for 4 months or so. I've really just barely started getting better lately. Luckily one of the few things I'm good at is learning fast, and in the past few weeks I've started learning about inheritance, abstract classes, virtual methods, Lambda expressions, etc, and they help a lot. Still, things that have to do with math still elude me a bit. Since I've forgotten most my math already, lol.

    And well, I think it's always best to help each other out. It speeds things up. That's why I'm trying to help as much as I can with the wikia, you never know when someone will post something you were trying to figure out how to do yourself, and you may also end up helping others with your own stuff. That way everybody wins :)

    Ah, and if I can I'll post you FinalIK actions in the wikia. It'll be any time between now and the next 5 days or so, there's also another 4 posts or so I want to use as a base for wikia articles. But I'm kinda busy right now (working on some features), so it may take me a bit to get to that.

    Anyway, you take care too!
  • edited September 2016
    Hi! Just letting you know I've posted your FinalIK actions in the AC wikia. You can check them out here and here. As usual, you are free to modify or add to the articles if you don't like something or want to update anything. Anyways, thanks for the great work :) 

    If I can I'll try checking about the interpolation in the scripts, but I don't currently have the FinalIK in my projects to test it... You would probably need to create a duration variable, then use lerping or inverse lerping to transition the variables that need it.

    you could try something like this, I guess:

    using System.Collections

    private IEnumerator Interpolate(float target, float startingValue, float finalValue, float duration)
    var elapsedTime : float = 0;

    //a loop inside a coroutine is a good, less expensive replacement for the update function.
    while (elapsedTime < duration) 
    target = Mathf.Lerp(startingValue, finalValue, (elapsedTime / duration));
    elapsedTime += Time.deltaTime;

    To call it just use: 
    Mind you, this is linear interpolation. Also, I do recommend using MEC coroutines over Unity ones though, you can get the free version here.

    Anyway, take care!
  • You are amazing. Thank you so much. I am going to play with this again a bit and see if I can't get a better handle on it. If I do, I'll update the wiki accordingly. I have the other ik action to post as well. What's the preferred process? Should we post them here first or just post them there?
  • edited September 2016
    Both are fine I guess, you can post them here first or you can post them in the wikia directly if you want. I don't mind doing the transplant if you don't have the time. Still, there's not much required to post, you just need to click the Contribute button at the top, then add a page. Then just add a description and explanation of what the script or tip does, and then just post the script or tip. Last, when the page is already created, you have to scroll down and at the bottom of the new page there will be a bar to input a category. There's only two right now: General and Integrations. Once that's done you are good to go :) 

    Ah, by the way I didn't notice but I created the var for the wrong language (guess I was tired, I kinda ended up mixing it up through the sentence, lol :P), proper C# should be: 

    var elapsedTime = 0f;

    You may need to use yield return null; instead of just yield; too, but do test it first, heh.
  • edited September 2016
    Oh, duh, I was forgetting, AC actions are ScriptableObjects not monobehaviors... That means Unity coroutines are not supported, so you only really have two or three options for running that code:
    1-You can use MEC coroutines which work in any class (and which I love, you can chain them, tag them for killing them later without hassle, specify what loop to use-Update,fixedupdate, slowUpdate, etc-, less garbage, more wait options, etc). 
    2-You can ditch the coroutine method and use a normal method, then call it as a regular method inside the AC run method (but it could have bit more overhead/garbage), Or 
    3-in a monobehaviour script, you can create a method that calls the coroutine as a middle man, then call that from the AC Action. sort of like:

    public class MyMonoScript : MonoBehaviour
    public void RunMyCoroutine(float target, float startValue, float maxValue, float duration)

    private IEnumerator Interpolate(float target, float startingValue, float finalValue, float duration)
    //then inside the action:
    GameObject myObject = new GameObject();  

    var script = myObject.GetComponent<MyMonoScript>();

    script.RunMyCoroutine(parameters for value a);
    script.RunMyCoroutine(parameters for value b);
    script.RunMyCoroutine(parameters for value c);
  • Using StartCoroutine() in Components / Actions ...
    Getting Down and Dirty & there is @Alverik again =D> :-) :- Having just wasted a day trying to sort StartCoroutine() in Custom Actions : I think this should be highlighted : "AC actions are ScriptableObjects not MonoBehaviours... That means Unity coroutines are not supported"
    Work'ins like internaly instantiating MonoBehaviour instances are littered with trip-ups (Although hats off for the Middleman class) - I have now become a MEC coroutines convert (Free & Pro version on the Asset Store : I say that because I had to Google it , not realising) : so this is another pat on the back for @Alverik & commented here to save numpties like me a lot of searching and trail & error...
  • Though it won't be appropriate for every situation, an Action's Run() function can be used like a co-routine of sorts in that returning a positive float value will cause the function to be re-run that value in seconds later.  Returning Time.deltaTime, for example, will make it the equivalent of FixedUpdate.

    You can use this trick to re-run an Action as many times as you need until you're ready for it to end by returning zero.
  • edited September 2016
    Chris is right, AC actions can already run like a coroutine. I use MEC in some of mine because it offers plenty of functionality that other coroutines don't (hell, yeah :) ). Also, in the example above I was thinking of the possibility of running separate coroutines, which may or may not have needed to be run at the same time. But, In most cases, AC's own method should be enough. Still, you can use my examples in any ScriptableObjects you might want to use or make, so it's nice stuff to keep in mind. (Although, with MEC that's unnecessary, lol)

    Still, kudos for getting MEC! :D I really love that asset :)
    AC and MEC are my most used plugins after all :)>-
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!