File size: 1,276 Bytes
8438369 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | extends Node
func get_aabb_corners(aabb_instance):
# If working in 3D and you need the corners on a specific plane (e.g., the "top" face)
# Assuming the Y-axis represents height and you want the top corners:
var front_left: Vector3 = aabb_instance.position + Vector3(0, aabb_instance.size.y, 0)
var front_right: Vector3 = aabb_instance.position + Vector3(aabb_instance.size.x, aabb_instance.size.y, 0)
var back_left: Vector3 = aabb_instance.position + Vector3(0, aabb_instance.size.y, aabb_instance.size.z)
var back_right: Vector3 = aabb_instance.position + Vector3(aabb_instance.size.x, aabb_instance.size.y, aabb_instance.size.z)
return {
'fl': front_left,
'fr': front_right,
'bl': back_left,
'br': back_right
}
func get_random_position_aabb(aabb):
var random_x = randf_range(aabb.position.x, aabb.position.x + aabb.size.x)
var random_y = randf_range(aabb.position.y, aabb.position.y + aabb.size.y)
var random_z = randf_range(aabb.position.z, aabb.position.z + aabb.size.z)
return Vector3(random_x, random_y, random_z)
# Try to get a random point distance away from origin point.
# The point should be inside the aabb's bounding box
func get_random_position_aabb_distanced(aabb: AABB, origin: Vector3, distance: float):
# TODO: Implement me
pass
|