This document is about: FUSION 2
SWITCH TO

Magnets

Fusion XR prototyping addons

The Magnets addon provides a simple way to attract an object to others when it has been ungrabbed.

Magnets demo

Magnet types

Magnetic object are described with the IMagnet interface. Several kinds of magnets exist.

MagnetPoint

MagnetPoint are network behavior, that will look for an IMagnet within their magnetRadius (with a Physics.OverlapSphere) to be attracted to them.

MagnetTarget

MagnetTarget can attract other objects, but won't move. They do not need to be placed under a NetworkedObject.

If isPlaneMagnet is set to true, instead of attracking object to their transform's position, the MagnetTarget attract them to the neareast point to the projection plane it defines with new Plane(transform.up, transform.position).

If alignOnAllAxis is set to false, the attracked object will align its up axis with the magnet target y axis, but will leave the other axis untouched.

MagnetCoordinator

An object can contain several MagnetPoint. To make sure they they do not trigger all at once upon ungrab, but only the one the closest to a magnetic object, a MagneticCoordinator can be used. It prevents the MagnetPoint from looking themselves for a target, and will select the most appropriate magnet point based on its distance from a magnetic object.

Demo

A demo scene can be found in Assets\Photon\FusionAddons\Magnets\Demo\Scenes\ folder.

Dependencies

  • XRShared addon 2.0

Download

This addon latest version is included into the Industries addon project

It is also included into the free XR addon project

Supported topologies

  • shared mode

Changelog

  • Version 2.0.2: Add onSnapToMagnet event
  • Version 2.0.1:
    • Fix to avoid magnet to try to attract to itself in some cases
    • Allows to set MagnetTarget axis for plane magnets
  • Version 2.0.0: First release
Back to top