Grabbables are one of ViRSE primary systems of user-environment interaction. They allow GameObjects to be picked up, moved and manipulated by players

Grabbables come in three types

  1. FreeGrabbables: Allows objects to be picked up and moved freely
  2. ConstrainedGrabbables: Allows grabbables to be given translation or rotation constraints, allowing you to make doors, drawers, pendulums, etc
  3. Adjustables: Similar to Activatables, these can be adjusted to the user and will emit a float value that you can pass to your plugin code. Unlike other grabbables, these have no physics!

All Grabbables share some common functionality

Receiving grabs and drops

//Link this function to the OnGrabbed event in the Grabbable's inspector
public void OnGrabbableGrabbed(string playerID)
{
		Debug.Log($"Player with ID {playerID} grabbed the grabbable!");
}

Triggering behaviors through code

//Expose reference to GameObject in inspector
[SerializeField] private GameObject gameObjectWithVirseComponent;

//Reference to the component's interface, in this case, IGrabbable
private IGrabbable virseComponent => gameObjectWithVirseComponent.GetComponent<IGrabbable>();

//An example of programmatically forcing the local user to drop the grabbable
private void ForceLocalUserDrop()
{
		if (virseComponent.IsGrabbedByLocalUser())
				virseComponent.ForceLocalUserDrop();
}

FreeGrabbables and ConstrainedGrabbables share further functionality