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

On Collision Stay 2D#

Physics 2D / On Collision Stay 2D

Description#

Executed when a game object stays in collision with a collider with a Rigidbody2D

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("On Collision Stay 2D")]
    [Image(typeof(IconCollision), ColorTheme.Type.Lime, typeof(BadgeDot))]
    
    [Description("Executed when a game object stays in collision with a collider with a Rigidbody2D")]
    [Category("Physics 2D/On Collision Stay 2D")]
    
    [Keywords("Collider")]

    [Serializable]
    public class TriggerCoreCollisionStay2D : TriggerHandleSourceBase<HandleOnCollisionStay2D>
    {
        // EXPOSED MEMBERS: -----------------------------------------------------------------------
        
        [SerializeField]
        private TValueOrAny<GetGameObject> m_Collide = new TValueOrAny<GetGameObject>();
        
        // PROPERTIES: ----------------------------------------------------------------------------

        protected override string GetTitle(GameObject source) => $"{this.SourceName} Collision Stay {this.m_Collide}";

        // OVERRIDE METHODS: ----------------------------------------------------------------------
        
        protected override void OnTrigger(GameObject target)
        {
            using Args args = Args.Get(this.Component, target);
            if (this.m_Collide.IsSpecific && this.m_Collide.Value.Get(args) != target) return;
            
            this.Run(args);
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.