Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Overlap Box 3D#

Physics 3D / Overlap Box 3D

  • Can Read

  • Cannot Write

Description#

Returns all 3D colliders that overlap with a box

Parameters#

Name Description
Center The center point of the box in 3D space
Size The total size (width, height, and depth) of the box
Rotation The rotation of the box as Euler angles (X, Y, Z)
Layer Mask Filter to check objects only on specified layers
Use Triggers Whether to check for Colliders marked as triggers or not

Code#

using System;
using System.Collections.Generic;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Overlap Box 3D")]
    [Category("Physics 3D/Overlap Box")]
    
    [Description("Returns all 3D colliders that overlap with a box")]
    [Image(typeof(IconCubeOutline), ColorTheme.Type.Lime, typeof(BadgePhysics))]
    
    [Parameter("Center", "The center point of the box in 3D space")]
    [Parameter("Size", "The total size (width, height, and depth) of the box")]
    [Parameter("Rotation", "The rotation of the box as Euler angles (X, Y, Z)")]
    [Parameter("Layer Mask", "Filter to check objects only on specified layers")]
    [Parameter("Use Triggers", "Whether to check for Colliders marked as triggers or not")]
    
    [Keywords("Inside", "Box", "Cube", "Rectangle", "3D")]
    
    [Serializable]
    public class TypeCollectionGameObjectsPhysics3DOverlapBox : TypeCollectionGameObjects
    {
        private static readonly Color GIZMO = new Color(0f, 1f, 0f, 0.25f);
        
        private static readonly Collider[] HitsBuffer = new Collider[128];
        
        [SerializeField] private GetVector3 m_Center = new GetVector3();
        [SerializeField] private GetVector3 m_Size = new GetVector3(Vector3.one);
        [SerializeField] private GetVector3 m_Rotation = new GetVector3(Vector3.zero);
        
        [SerializeField] private LayerMask m_LayerMask = Physics.DefaultRaycastLayers;
        [SerializeField] private GetBool m_UseTriggers = new GetBool(false);
        
        public override void Get(Args args, List<GameObject> values)
        {
            Vector3 center = this.m_Center.Get(args);
            Vector3 size = this.m_Size.Get(args);
            Vector3 rotation = this.m_Rotation.Get(args);
            
            QueryTriggerInteraction triggerInteraction = this.m_UseTriggers.Get(args) 
                ? QueryTriggerInteraction.Collide 
                : QueryTriggerInteraction.Ignore;
            
            int numHits = Physics.OverlapBoxNonAlloc(
                center,
                size * 0.5f,
                HitsBuffer,
                Quaternion.Euler(rotation),
                this.m_LayerMask,
                triggerInteraction
            );
            
            GizmosManager.Cube(center, Quaternion.Euler(rotation), size, GIZMO, GizmoMode.Outline, 0.25f);
            
            values.Clear();
            for (int i = 0; i < numHits; ++i)
            {
                Collider collider = HitsBuffer[i];
                if (collider != null) values.Add(collider.gameObject);
            }
            
            Array.Clear(HitsBuffer, 0, numHits);
        }

        public override string ToString()
        {
            return $"Overlap Box 3D at {this.m_Center} size {this.m_Size}";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.