Conversation
There was a problem hiding this comment.
Most of the changes focused on setting the player/box/target spawn positions to avoid the player falling outside of the area, spawning at the edges, or inside of a box. Player position is also randomized now.
Feel free to ask about any other changes. It's not necessarily an ideal solution, it's just one way to keep the AABB overlap checks and get everything working. I haven't done any further optimizations in this update.
There are a few more small changes in the code than mentioned, unfortunately the diff is not great in this case as it seems my Godot Editor changed a lot of the formatting.
| class_name AICharacter | ||
|
|
||
| ## A reference to the main mesh, used for AABB overlap checks | ||
| @export var aabb_mesh: Mesh |
There was a problem hiding this comment.
| var total_area = ground.size.x * ground.size.z | ||
| var max_objects = int(total_area) | ||
|
|
||
| #region Sets a few free positions for character and target to spawn |
There was a problem hiding this comment.
Added to ensure there's always some free space between character/target and the boxes. While it limits the amount of random positions, this is one way to fix the player or target sometimes getting spawned inside of a box, while not requiring the entire level to regenerate on reset. Sometimes the character got stuck at the edges (at least with my other modifications, not sure about the original), so a padding parameter was added to the random position method.
|
|
||
| func _physics_process(_delta: float) -> void: | ||
| if not placed and raycast.is_colliding(): | ||
| if use_raycast_positioning and (not placed) and raycast.is_colliding(): |
There was a problem hiding this comment.
Disabled the raycasting by default, we use the boxes on a flat level (the uneven terrain uses trees). If we use boxes on such terrains in the future, this can be enabled in code.
| [sub_resource type="BoxShape3D" id="BoxShape3D_qe6ow"] | ||
| size = Vector3(2.9668, 3.03027, 2.74463) | ||
|
|
||
| [node name="BoxLargeGreen" type="StaticBody3D"] |
There was a problem hiding this comment.
Changed the boxes to static bodies, as the CSGBoxes wouldn't work with raycast exceptions.
- Removes the previously added collision layer (unnecessary)
|
During training, character still sometimes fell (on uneven terrain in the test case). I added a debug message for that. Not sure whether the changes cause this, it needs some further look. |


Update to the behaviors env. There are a lot of changes due to using a different IDE or settings (I use Godot 4.3 built-in editor), I'll highlight the important ones however.