Skip to content

Updates Behaviors 3D#47

Open
Ivan-267 wants to merge 2 commits intobehaviors_3dfrom
behaviors_3d_update
Open

Updates Behaviors 3D#47
Ivan-267 wants to merge 2 commits intobehaviors_3dfrom
behaviors_3d_update

Conversation

@Ivan-267
Copy link
Copy Markdown
Collaborator

@Ivan-267 Ivan-267 commented Jan 9, 2025

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.

@Ivan-267 Ivan-267 requested a review from edbeeching January 9, 2025 22:26
Copy link
Copy Markdown
Collaborator Author

@Ivan-267 Ivan-267 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to the character and target, used to leave some free spawn positions and position the character/target.
For now it's just a copy paste of the main mesh in the editor, this creates a reference to the same resource, but also allows using a different AABB mesh if needed.

image

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
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

image


func _physics_process(_delta: float) -> void:
if not placed and raycast.is_colliding():
if use_raycast_positioning and (not placed) and raycast.is_colliding():
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"]
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the boxes to static bodies, as the CSGBoxes wouldn't work with raycast exceptions.

- Removes the previously added collision layer (unnecessary)
@Ivan-267
Copy link
Copy Markdown
Collaborator Author

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.

@Ivan-267 Ivan-267 added the Env Update Updates an environment (compatibility, bugfix, or new features) label Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Env Update Updates an environment (compatibility, bugfix, or new features)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant