Dr.
Tim Lammarsch

Following up on the recent publication on Visualization using the Unity3D engine, I did some further testing on how Unity3D can be applied. I realized that especially for beginners, not everything is explained as simple as needed. There are also a lot of video guides, but I belong to a group of people who rather read up on stuff. Consequently, I solved some problems and decided to disclose those results here. (I omitted the "checked" date for the links, please inform me about dead links – thank you.)

Unity3D FAQ (from a Personal Perspective)

[2D] How do I convert screen coordinates to world coordinates?

The typical method you find for 3D coordinates (Camera.ScreenToWorldPoint) will not work as expected in 2D. The solution that worked for me is based on this thread:

Camera camera = Camera.allCameras[0]; // primitve; use the way fitting for you // get the plane were your objects are (assuming camera looking from z: xy-plane) Plane basePlane = new Plane(Vector3.forward, Vector3.zero); Ray ray = camera.ScreenPointToRay(screenPosition); float distance; basePlane.Raycast(ray, out distance); Vector3 worldPosition = ray.GetPoint(distance);

[2D] Friction does not work – why?

Make sure that you are aware of how to use materials. If you are changing the friction a run-time, there seems to be a bug solved in this thread. For me, however, there was another problem: I used a Circle Collider 2D. This collider seems to actually create a "rolling" object (still working on this), as expected from real world. Thus, if you want friction slowing down an object, use something like a Box Collider 2D.

How do a load another scene?

I found a video guide, yet it seems to partially use deprecated functions. You can load a scene from a script by calling

SceneManager.LoadScene("SceneName");

The name of the scene can be set in the Unity development environment. For the scene to be loadable that way, you need to open the build settings (Ctrl+Shift+B) and drag it into the list of scenes in the build.

This is a private web site. Commercial information (including imprint): www.lammarsch.at.