(MRTK) How to make a cube behave like a toggle button?

I’m trying to to make a cube behave like a toggle button so that when I touch it it shouldn’t change it’s position on x-axis and z-axis only on y-axis. Also the augmented hand shouldn’t go inside that object.

I’m using MRTK and implement in HoloLens 2.

Use this on on cube… and Change your hand’s tag to “Player” or “Hand”

// will show (0,0,0) in inspector , only chnage middel value which is y ( x , y , z)
[SerializeField] private Vector3 offset;

private void OnCollisionEnter(Collision coll)


private void ChangePos()

transform.position = transform.position + offset;


I’m not sure how to make any gameobject for hands in MRTK.

For MRTK questions, we generally recommend referencing the Microsoft Mixed Reality forums: Mixed Reality - Microsoft Community Hub

This is because Microsoft owns and maintains their AR Foundation provider plug-in and build tools. (As opposed to a handful of other providers plug-ins that are maintained by Unity).

That said, I think what goonslayer44 is suggesting is a good general idea for how to make a cube behave like a toggle button.