Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.
Use of a singleton instead of a BlackboardDédéHi. I have a question regarding the use of a blackboard to keep track of data commonly used by multiple nodes (like in this example the global position of the player). What about using a singleton in the Project's autoload instead of including that type of data in a AI class? 62Sep. 17, 2024
Blackboard class missing bool?earnest-meerkatI am trying to convert this code into C# and I have a question about the "
```javascript
Blackboard.is_player_dead:
```
" portion of the code. Is there some sort of boolean that is supposed to be in the Blackboard class? I don't see anything in the example code.11Oct. 30, 2024
Is there a file missingDédéIn the Getting a reference to the player, it is mentioned to modify the script res://lessons/player_3d.gd, but I don't see that file in the File System. Is it something that I have missed?31Sep. 16, 2024
Visualizing Mob's Vision Cone and Rangewavy-wildcatHi, I was inspired to create a visualization for the mob's vision ranges as I thought it would be both a good exercise and a way to prototype some stealth sections in my game. I'm more asking this question to get feedback on what I did, and if you had any suggestions for improvement, or places where I could find alternative solutions (I was struggling to find references for this problem).
For my solution I used a MeshInstance3D with a shader. I found a dial shader by [Steampunkdemon](https://godotshaders.com/author/steampunkdemon/) on the godot shaders forum and modified it to only include one sector of a dial with a transparent background. The Sector start and end positions are shader parameters. I attached a script to the MeshInstance3D and instantiated it as its own scene. I would then attach this to a mob as its direct child.
The thing is, I feel like accessing the ShaderMaterial and parent this way feels wrong as I'm directly accessing above and below the node. Is there a better method for modifying the shader resources without the script needing to moderate the two? I was considering adding the code for updating the vision cone on the mob script, but the purpose of making the vision cone was for it to be modular - adding code in the mob script looking for the cone to update it would be wasteful.
As an aside to this massive post, thank you so much for this tutorial series, I've learned immensely from the lessons and love your YouTube videos! Looking forward to the future modules!
```gdscript
extends MeshInstance3D
@onready var parent := get_parent()
@onready var coneMat : ShaderMaterial = $".".mesh.material
func _ready() -> void:
if parent != null:
var vision_range = parent.get("vision_range")
var vision_angle = parent.get("vision_angle")
scale = Vector3(vision_range, 1.0, vision_range)
if coneMat:
# the .5 is from the origin of the cone. Sector3 expands the left side,
# and sector_end expands the right. Two sides of the circle immitate a center cone.
coneMat.set_shader_parameter("sector3", .5 - (visionRadiansToPercentage(vision_angle)))
coneMat.set_shader_parameter("sector_end", .5 + (visionRadiansToPercentage(vision_angle)))
else:
print("NO MATERIAL")
else:
print("NO PARENT")
# Converts radians from parent mob to a percentage of a circle
func DegToPercentConverter(visionRadiansToPercentage: float) -> float:
return (visionRadians * 180/PI)/360
```10Jan. 03, 2025
A bit confusedRudiThe references in the previous section mentioned `res://lessons/ai.gd` and `res://lessons/mob_3d.gd` and in here it's referenced as `res://ai.gd` and `res://mob_3d.gd` which threw me off a bit. It took a bit of back and forth to confirm I was on the right track. I assume they should be under the `lessons` folder?20Sep. 24, 2024
"More on Dot Product" doesn't link to anywherevast-baboonThe glossary callout in "Coding the idle and look at player states" section doesn't have a link attached to "More on Dot Product". There is an entry in the glossary that's easy enough to find, so it's no big deal: [https://school.gdquest.com/glossary/dot_product](https://school.gdquest.com/glossary/dot_product)10Sep. 20, 2024
I'm getting a print message regarding a missing transition whenever I activate the mob's state machine.Brain Siege GameworksI've got this print message whenever I try to activate the mob's state machine with the idle state: `Trying to trigger event PLAYER_ENTERED_LINE_OF_SIGHT from state Idle but the transition does not exist.`
`At: res://lessons/ai.gd:143:trigger_event()`
This is clearly the transition event. However I don't know why the transition does not exist.
Through some printing, it seems it's trying to get a 3rd dictionary item which does not exist.120Sep. 18, 2024
How could I go about separating the states into their own files?late-alligatorHello, I just finished this module, and I'm tinkering around with the state machine concept. I was wondering how I could break the states of the state machine out into their own files. I think in my own projects I would prefer to have the states, the state machine, and the blackboard all in one file, but I am a little bit lost on how to do that in GDScript. For the challenge, I created a StateWait2 class in a separate file but I can't figure out how to access it from the mob_dummy_3d file
p.s. this is my favorite module so far! your approach to state machines is different from what I'm used to, but there's a ton of useful information here and I think this is great!10Sep. 14, 2024
Lesson Q&A
Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.