Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

best practice for populating variables vis custom resource#319

Answeredbylimbonaut
mccrae-ben asked this question inQ&A
Discussion options

assuming my agents have a custom resource like "AgentStats" that define core stats like "base_speed" what is the best practice for populating the Blackboard.

As I understand it, is this the best way:

  • create the "base_speed" var in the Blackboard
  • in the Agent script, reference the agent's BTPlayer and set the blackboard_plan's "base_speed" variable
@export var agent_stats: AgentStats //custom resource defining core stats for this agent@onready var bt_player: BTPlayer = $BTPlayerfunc _ready():bt_player.blackboard.set_var("my_speed", agent_stats.base_speed) //set the blackboard variable to the agent stats value
You must be logged in to vote

It depends on what you need. You could also just pass the resource and work with it instead.

Or, you could write a general-purpose function to add variables from a resource like that (provided you want the same names as the property names):

for prop_info in my_resource.get_property_list():    if prop_info.usage & PROPERTY_USAGE_SCRIPT_VARIABLE and prop_info.usage & PROPERTY_USAGE_STORAGE:        blackboard.set_var(prop_info.name, my_resource.get(prop_info.name))

Replies: 1 comment

Comment options

It depends on what you need. You could also just pass the resource and work with it instead.

Or, you could write a general-purpose function to add variables from a resource like that (provided you want the same names as the property names):

for prop_info in my_resource.get_property_list():    if prop_info.usage & PROPERTY_USAGE_SCRIPT_VARIABLE and prop_info.usage & PROPERTY_USAGE_STORAGE:        blackboard.set_var(prop_info.name, my_resource.get(prop_info.name))
You must be logged in to vote
0 replies
Answer selected bymccrae-ben
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@mccrae-ben@limbonaut

[8]ページ先頭

©2009-2025 Movatter.jp