0
Answered

Programming

JPAC 3 years ago updated by Nimvoker 2 years ago 11

Hi,

I'm interested in purchasing, but I am a programmer.  I am looking to use the visual state machine feature, but I would like to code my states, is that possible with this?  I am basically just looking for a visual tool to handle the transitions to the states, but the states I want to code themselves.  Like some sort of an Update() on each state.  Can this be done?

Sorry if this is a novice question, it seemed geared towards more non-programmers.

Thanks!


Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

Answer

+2
Answer

Yes you can code everything and just use the state machine to connect it all. 

When you create a state machine, you double click a "state" and various events for on update, start, on transition, ect become available on a graph. Since you have access to all your scripts, you can now use your script as nodes or blocks by right click and browsing or typing to search for your class, variables, and functions you have on your script.  You can then connect other various elements and manipulate at a higher level.. How much you leave up to Bolt is you're choice.

Example, say I have a character controller I did in a script, and want to know if it's grounded because I made a bool return method.. I can create all the variables, arguments, outputs, methods, ect. So b say there is that as a method, Result being grounded or not. Save it. Nothing special from the Bolt API is needed. Go back to unity, right click in a graph, search for character controller function and it's a node on your graph. You can use the result to determine a change on the state machine.

Or you can visually script it all, really not too much limitation here. Do all programming and just state changes are fine.

Maybe this will help you decide-

http://support.ludiq.io/topics/223-custom-types/

Anything you code yourself is accessible as nodes/units as well. Any exceptions I believe are noted in the docs. 

Thanks William,

This brings code into this world, but I am looking into coding each state.

For example, let's say I have a character state "Follow".  In this state I want to code the logic on how my character follows his target.  It's easier for me to do this via code.  But I want to use the visual aspect to control the flow (i.e. Health < 10 then go to "Flee" state).  Can I add a script to a state somehow?  Is that possible?

Thanks!

I believe that is exactly what I so un-elegantly said, ha.  State Machines use the same nodes/units as Flow Machines, so anything you code can be turned into nodes/units for use in either. 

Take a look here-

http://support.ludiq.io/forums/4-bolt/categories/38-basic-concepts/topics/

And here-

http://support.ludiq.io/forums/4-bolt/categories/40-state-graphs/topics/

I am just a user myself, but based on my understanding of your question and my use so far, I am pretty sure I am correct.

Hi William,

Sorry, I guess I still don't see how.  All I see is node based manipulation, but nothing says I can make a state using a script or controlling a state from a script.

If you're a user, are you able to do that?  Do you have to double click on a state to create a script file or how would I hook into a state via c# script?

Thanks!!


I think the issue is my explanation. I am a mediocre coder at best and more visual  and you seem to be a Coder 1st. Best to leave this one for Lazlo or another better versed coder in the forum as i am not quite sure how to explain it better at this time.

+2
Answer

Yes you can code everything and just use the state machine to connect it all. 

When you create a state machine, you double click a "state" and various events for on update, start, on transition, ect become available on a graph. Since you have access to all your scripts, you can now use your script as nodes or blocks by right click and browsing or typing to search for your class, variables, and functions you have on your script.  You can then connect other various elements and manipulate at a higher level.. How much you leave up to Bolt is you're choice.

Example, say I have a character controller I did in a script, and want to know if it's grounded because I made a bool return method.. I can create all the variables, arguments, outputs, methods, ect. So b say there is that as a method, Result being grounded or not. Save it. Nothing special from the Bolt API is needed. Go back to unity, right click in a graph, search for character controller function and it's a node on your graph. You can use the result to determine a change on the state machine.

Or you can visually script it all, really not too much limitation here. Do all programming and just state changes are fine.

Thanks William & ThePositiveMoxie, you got yourself another sale :)

+1

Btw, there is an API if you wanted to handle state changes in a script. The API documentation is still being put together though. So you'd have to trial and error there in the mean time.

What is the name of that API?