Magic Leap (Unity on a Mac) by Example: Part 5
More complete example using a range of the Magic Leap APIs.
This article is part of the series starting with Magic Leap (Unity on a Mac) by Example: Part 1.
In the first four articles, we explored each of the MLHands, MLInput, MLWorldPlanes, and MLWorldRays APIs through trivial examples. In this article, we use them together to build a slightly more complicated example.
Ball Drop Example
This example is available for download in a separate repository.
While a bit unsavory (will not scale well), all of the functionality is implemented in the Ball.cs script on the Ball GameObject.
At startup the Ball (blue sphere) is rendered, the APIs are started, and the horizontal planes and the floor (transparent blue planes) are detected.
Assets/src/Ball.cs
If the user makes a fist with their right hand, the ball will drop and bounce on the obstacle below it.
Assets/src/Ball.cs
If the user uses the first touch control (left / right / up / down) it will move the ball horizontally.
Assets/src/Ball.cs
When ball moves above an obstacle, it will float its height to maintain a constant height above obstacles (including floor).
Assets/src/Ball.cs
When Unity stops, the APIs are stopped.
Assets/src/Ball.cs
Conclusion
Hope you found this series helpful.