gd-YAFSM
gd-YAFSM copied to clipboard
gd-YAFSM Godot 4.0 port
Port of gd-YAFSM for Godot 4.0 WIP
Linked issue #46 Linked discussion #42
I couldn't get this working. After adding to my project and enabling the addon, nothing new showed up in the "Create new node" panel.
After further inspection, I noticed these warnings:
scene\resources\resource_format_text.cpp:431 - res://addons/imjp94.yafsm/scenes/StateMachineEditor.tscn:3 - ext_resource, invalid UUID: uid://ccv81pntbud75 - using text path instead: res://addons/imjp94.yafsm/scenes/StateNodeContextMenu.tscn scene\resources\resource_format_text.cpp:431 - res://addons/imjp94.yafsm/scenes/transition_editors/TransitionEditor.tscn:3 - ext_resource, invalid UUID: uid://dg8cmn5ubq6r5 - using text path instead: res://addons/imjp94.yafsm/assets/icons/add-white-18dp.svg scene\resources\resource_format_text.cpp:431 - res://addons/imjp94.yafsm/scenes/transition_editors/TransitionEditor.tscn:4 - ext_resource, invalid UUID: uid://b2coah58shtq1 - using text path instead: res://addons/imjp94.yafsm/assets/icons/subdirectory_arrow_right-white-18dp.svg scene\resources\resource_format_text.cpp:431 - res://addons/imjp94.yafsm/scenes/condition_editors/BoolConditionEditor.tscn:3 - ext_resource, invalid UUID: uid://blnscdhcxvpmk - using text path instead: res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.tscn scene\resources\resource_format_text.cpp:431 - res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.tscn:3 - ext_resource, invalid UUID: uid://cie8lb6ww58ck - using text path instead: res://addons/imjp94.yafsm/scenes/condition_editors/ConditionEditor.tscn scene\resources\resource_format_text.cpp:431 - res://addons/imjp94.yafsm/scenes/condition_editors/IntegerConditionEditor.tscn:3 - ext_resource, invalid UUID: uid://blnscdhcxvpmk - using text path instead: res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.tscn scene\resources\resource_format_text.cpp:431 - res://addons/imjp94.yafsm/scenes/condition_editors/FloatConditionEditor.tscn:3 - ext_resource, invalid UUID: uid://blnscdhcxvpmk - using text path instead: res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.tscn scene\resources\resource_format_text.cpp:431 - res://addons/imjp94.yafsm/scenes/condition_editors/StringConditionEditor.tscn:3 - ext_resource, invalid UUID: uid://blnscdhcxvpmk - using text path instead: res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.tscn scene\resources\resource_format_text.cpp:431 - res://addons/imjp94.yafsm/scenes/transition_editors/TransitionEditor.tscn:6 - ext_resource, invalid UUID: uid://cnkaa2ky1f4jq - using text path instead: res://addons/imjp94.yafsm/assets/icons/compare_arrows-white-18dp.svg
But to be honest, it seems that something else is the real cause of the issue
Info: Godot 4 on this commit
nothing new showed up in the "Create new node" panel.
This is normal. In fact, I submitted a PR to the Godot repository to fix this issue.
Meanwhile, you need to create a Node and link StateMachinePlayer to it.
Thank you for your effort! Currently integrating in a Godot 4.0 alpha 13 project. For the time being I had to make two edits to your proposal:
- in FlowChart.gd line 356, I had to substitute
content_position(event.position)
withcontent_position(get_local_mouse_position())
.event.position
was not updating when releasing a connection, always setting the "to" node to the original "from" node. - in StateMachineEditor.gd line 559, I had to substitute:
if is_instance_valid(_reconnecting_connection.from_node) and _reconnecting_connection.to_node.name == to:
with
if is_instance_valid(_reconnecting_connection.from_node) and \
_reconnecting_connection.from_node.name == from and \
is_instance_valid(_reconnecting_connection.from_node) and \
_reconnecting_connection.to_node.name == to:
because of a previously freed
error.
The 1st change I had to make is particularly strange, it doesn't happen when not making a connection - eg. if you press on a node and drag it above another one, the event.position
gets updated on mouse release without any issue. I suspect it's some sort of editor bug.
Thanks again, I hope this is useful!
I'm actually pretty invested in this & would be willing to contribute to a port to Godot 4.0. Perhaps when Godot 4's in beta? I was hoping to use this along with the Beehave addon to basically create an HFSM + Behavior Tree hybrid for my game's AI systems. Although rolling my own HFSM isn't terrible, the task of making a graphical editor for it is a non-trivial amount of dev time & this add-on seems to be pretty workable already.
This seems mostly functional in Alpha 13! Unfortunately I can't make connections inside of the editor, but it's possible to create the state machine map in 3.X using the main YAFSM, save it as a tres, and then load it into 4.0 to work from there.
@cheesycoke have you tried my corrections?
Thank you for your effort! Currently integrating in a Godot 4.0 alpha 13 project. For the time being I had to make two edits to your proposal:
- in FlowChart.gd line 356, I had to substitute
content_position(event.position)
withcontent_position(get_local_mouse_position())
.event.position
was not updating when releasing a connection, always setting the "to" node to the original "from" node.- in StateMachineEditor.gd line 559, I had to substitute:
if is_instance_valid(_reconnecting_connection.from_node) and _reconnecting_connection.to_node.name == to:
with
if is_instance_valid(_reconnecting_connection.from_node) and \ _reconnecting_connection.from_node.name == from and \ is_instance_valid(_reconnecting_connection.from_node) and \ _reconnecting_connection.to_node.name == to:
because of a
previously freed
error.The 1st change I had to make is particularly strange, it doesn't happen when not making a connection - eg. if you press on a node and drag it above another one, the
event.position
gets updated on mouse release without any issue. I suspect it's some sort of editor bug.Thanks again, I hope this is useful!
@farfalk Oh that's embarrassing, I tried it at first before making that comment but I just realized I misunderstood and copied one part wrong. That totally fixes it, thank you so much!
Good news! With my proposed changes and some additional renames, this extension works quite nicely in the latest Godot 4 alpha 16.
Additional renames:
- Control inherited
hint_tooltip
attribute ->tooltip_text
- CanvasItem inherited
update()
method ->queue_redraw()
- Core function
deg2rad
->deg_to_rad
However the running debug visualization still doesn't work, and there are some visual artifacts here and there.
I'll update the branch. Though, I'm using usually my other branch, port-4.0-expression
which integrates my suggestion to add custom expressions. So, sometimes, I tend to forget this branch.
I'll update the branch. Though, I'm using usually my other branch,
port-4.0-expression
which integrates my suggestion to add custom expressions. So, sometimes, I tend to forget this branch.
Maybe I'm going beyond my involvement here, sorry for that, but I think it could bring some value. @adamscott I don't know if it makes sense to merge in this port a feature proposal, usually a port aims for feature parity - and only then additional features are evaluated.
@imjp94 what do you think?
@farfalk Yes, I agree with that, but I think what @adamscott was saying is that he usually works on another branch instead of this, that's why he seldom push to this branch
@farfalk Yes, I agree with that, but I think what @adamscott was saying is that he usually works on another branch instead of this, that's why he seldom push to this branch
Yup, that I understood, but I see there's a commit (2fd2a16) in which he backported his proposal or part of it - am I right @adamscott ? I'm seeing differences in the way the condition resources behave and how they are shown, and those differences point to edits in that commit.
If I'm not mistaken, I'd suggest to remove the changes due to the proposal and leave only the edits related to porting.
If I'm mistaken, sorry!
@farfalk Oh, you are right. I never review the commits before =P
I am fine with it if this is temporarily and just meant for his convenience, as long as @adamscott mentioned this temporarily feature in the PR and willing to remove the commit before merging to master.
@farfalk My commit is not backporting expression nodes, just the other modifications that I made.
Nonetheless, I'm suggesting to squash this PR before merging master.
Getting an "Invalid get index 'name' (on base: 'bool'). error (in Transition.gd, line 26) when trying to run this in my project. The error only pops up when adding conditions to a transition.
Any ideas? I have a StateMachinePlayer in the scene, "Entry, Idle and Run" scenes added to it. Entry -> Idle has no Conditions and Idle -> Run has conditions. (As soon as I put conditions on it I get the above error).
@jdbhartley Unfortunately, I don't have time to work on gd-YAFSM at this very moment. I'll try to help as soon as I touch to the code.
Hi @adamscott , I opened another pull request (#50) with all the changes I had to make to bring it to feature parity, feel free to check it out and let me know how you propose to proceed - if you'd like to merge my proposal into yours or what else :)
Superseded by #50