Skip to content

Commit

Permalink
quick edits
Browse files Browse the repository at this point in the history
  • Loading branch information
default user name committed Oct 11, 2022
1 parent 0304ef4 commit 8dea143
Showing 1 changed file with 7 additions and 161 deletions.
168 changes: 7 additions & 161 deletions Documentation/2.1_Sample_Scenes.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,177 +155,23 @@
**Details about the code** - see the [Arduino documentation](./3.2_Arduino_Connection.md)


# Arduino Simple Sensors Scene



**Summary**: This example shows how send data to/from Arduino. In the process you will learn how to work with data channels, and how to see this data between multiple users.



<picture> <img src="https://github.com/shankar-r19/CYBS-MArkdown-files/blob/a11272c75b6382ec917246091b503b07adb3b9e1/Arduino_Simple_sensor.png"></picture>


* **Details**: This scene transfers data to/from Arduino and uses the following 5 data channels (see screenshot):
* Unity generates data in 3 channels (C1, C2, C3)
* C1 (square wave) and C2 (sine wave) are automatically generated by the “SimulatedChannels” gameobject
* C3 is user controlled through the “ManualDataChannelsStandalone” gameobject.
* Unity receives data from Arduino (in channels C4, C5)
* Arduino receives data from Unity (C3 only)
* Arduino generates data in 2 channels (C4, C5):
* C4 is half of C3 received from Unity
* C5 is a sawtooth signal
* The Arduino looks at C4 and if it is > 500 it turns on the onboard LED
</br></br>
* **How to run in Single user:**
1. Set up and run the Arduino
1. Open the Arduino IDE.
2. Connect an Arduino to the PC and upload the sketch found in the **External_IDE_Projects\ArduinoProjects\Unity5_UnityInputsSimple** folder.
3. Make a note of what port the Arduino is connected to (you’ll need to put this in Unity)
4. Open the SerialMonitor and check that the Arduino is sending serial data (you should see :C5:__ and :C4:__ values)
5. Keep it running on the Arduino (ie: don’t disconnect the USB port).
</br>
2. Set up and run the project in the Unity editor
1. Open the Unity project
1. If you haven’t already, set up your PhotonID as detailed in the instructions for SimpleScene.
2. Set up USB port
1. Search for the “**SerialController**” gameobject in the scene hierarchy. It might be disabled, that’s fine.
2. Change its “Port Name” to whatever the Arduino is connected to (you can find this in the Arduino IDE. If you are on windows, this will be something like “COM7”. If you are on Mac, you’ll need to copy the whole path from the Arduino IDE, including “/dev/”…)
3. Click Run in Unity
</br>
3. Play with it
1. You should see all sensors changing except C3 and C4.
2. In the GameView, use your mouse/keyboard to move around (read the [moving/interacting documentation](https://docs.google.com/document/d/11E8rnbJfgGQh4dxneZiqf222GhaeNIkoLftMDAjwl3g/edit#))
3. Move around and find the ManualDataChannel window (this is set to control the C3 channel). Then click on the two bottom-right buttons which toggle the channel between low and high values; or use the slider to change its values.
4. Observe the C4 from the Arduino become half the value of C3. Also observe the Arduino turn its onboard LED when C4>500.
5. **Known bugs**:
i. You will get a runtime error about object menu not being found; this is because this is a simple scene without object menu.
ii. There is an issue when sending too much continuous data from Unity to Arduino, whereby the Arduino doesn’t receive data properly so Unity-generated sensor values may be lost or may be received as wrong values (super big or low). So your changes to C3 might not always register on the Arduino if you send too much at once. The connection from Arduino to Unity seems not affected by this.
iii. Sometimes Unity hangs on start. Just restart.</br></br>
* **How to run in Multi user:**</br>
1. Follow the steps in the SimpleScene instructions to deploy the project on two clients.</br>
1. Observe the same graphs on both the Standalone and the Unity window, and all graphs should be synchronized. You can change the values from either user and the Arduino should respond appropriately. </br>
1. You can now send this app to anyone else and they should be able to control your sensor values & Arduino. </br></br></br>
* **Details about the code** - see the [Arduino documentation](./3.2_Arduino_Connection.md)


# A Simple Scene - Structure and First Execution



* **Summary**: In this example you’ll see the most basic scene (use this in all your scenes). If you run this on multiple clients you’ll see that multiple users can see each other, and create/modify objects together.
* **Summary**: The minimum you need for a scene are these objects (use this in all your scenes). You can create this cene by taking the Arduino multiplayer scene and removing all the extra objects. If you run a scene just containing this, you’ll see that multiple users can see each other, and create/modify objects together.
* <picture> <img src="./Simple_Scene.png" width="500" height="400"></picture>

* **Details:** The scene contains the following objects (use these in all your scenes):
* **Details:**
* **MRTK objects** (MixedReality Toolkit, Playspace, SceneContent)
* **– CYBS – objects**
* The **Base prefab** which is the core that makes everything work through Photon.
* The **Channels and Devices prefab** which sets up the data channels and connections to external devices like USB, signal simulators, Websockets, Gogo boards.
* The **World UIs prefab** which contains the menus for spawning multiplayer objects and for changing editing modes.
* A directional light
* A (disabled) Iulian’s Room 3d object; enable it so you feel part of a room.
</br></br>
### **How to run in Single user:**
10. Open this example scene
11. **Set up Photon** (you only need to do this once per Unity project)
i. Get a new Photon app id from the Photon dashboard [https://dashboard.photonengine.com/](https://dashboard.photonengine.com/).
ii. Enter this as the Photon App ID in the Photon “Highlight Network Settings” menu.
12. Run the project in the Unity editor
i. Click Run
ii. In the GameView, use your mouse/keyboard to move around (read the [moving/interacting documentation](https://docs.google.com/document/d/11E8rnbJfgGQh4dxneZiqf222GhaeNIkoLftMDAjwl3g/edit#))
iii. In the Scene view you should see yourself as a player moving around.
iv. Click on the object menu or image menu to spawn new objects and move them around.
</br></br>
### **How to run any scene in Multi user:**
* **Note: For multiple users, you will need one PC running the project in the Unity editor, and this needs to be started before all other users.**

13. Once the second user starts the app, you will see two player heads in the game (one from the PC Unity editor, and the other from your second app).
14. In one user, click on the object menu or image menu to spawn new objects and move them around, and watch them synchronized between multiple players.
15. You can now send this app to anyone else and they should be able to join you in the multiplayer setup. Note: The Photon ID makes people join the same game, so if you don’t want people joining, just change the Photon ID. </br></br>
* **Next steps:**
* If you want to expand on this scene with custom 3D objects, see the MultiplayerBasicObjects example.
* If you want to use the Arduino, see the ArduinoSimpleSensors example.


# Multiplayer Custom Objects Scene



* **Summary**: You can use this system to have multiple users view and manipulate your custom objects. This scene shows the different ways objects can be created & shared between multiple users.
* <picture> <img src="./Custom_Game_objects.png" ></picture>


* **How to run this project in Single and Multi player:** Follow the same instructions as for the SimpleScene example.
* **Details** (these are also described in the documentation about [multiplayer objects](./3.5_Multiplayer_Objects_Overview_and_Tutorial.md)
* There are 3 types of objects that can be shared in a multiplayer setup; choose the one that your users need.

<table>
<tr>
<td>
</td>
<td>
<strong>What can multiple users do with it?</strong>
</td>
<td><strong>What components does it need?</strong>
</td>
</tr>
<tr>
<td><strong>Static scene object</strong>
</td>
<td>Look
</td>
<td>Renderer
</td>
</tr>
<tr>
<td><strong>Synchronized scene object</strong>
</td>
<td>Look, Move, Modify
</td>
<td>Renderer
<p>
Collider
<p>
PhotonView (ownership: Takeover)
<p>
PhotonTransformView (sync: all)
<p>
PlayerCreatedObject
</td>
</tr>
<tr>
<td><strong>Object through creation menus</strong>
</td>
<td>Look, Move, Modify, Spawn multiple copies
</td>
<td>Renderer
<p>
Collider
<p>
PhotonView (ownership: Takeover)
</td>
</tr>
</table>




* **Static scene objects:** These are built with the scene and are not modifiable by users. Use this if you want all users to just look at the same objects. They are visible to all users, but cannot be moved/modified; and if a user does move them (ex: while running in the Unity editor) the object’s properties are not synchronized between users. The ManualCube_Static is an example of such an object.
* **How to create it before running:** It was created in the Unity editor by right-clicking on the scene and creating a 3D Cube object.
* **Synchronized scene objects**: These objects are built with the scene, and are modifiable by users. Use this if you want all users to look and manipulate objects. They are visible to all users and, when modified, their properties are synchronized between all users. The ManualCube_PlayerMoveable is such an example (*if you cannot find it in the scene while Unity is running, search for it by name because it will have been moved under the networked objects root).
* **How to create it before running:** It was created in the Unity editor by making a simple 3D Cube, then adding to it the following scripts:
* _PhotonView_: used by Photon to synchronize the object across users; note that ownership must be of type Takeover.
* _PhotonTransformView_: used by Photon to send/receive the object’s transform; note that all the object properties are synchronized.
* _PlayerCreatedObject_: used by our system to let users move/edit the object. This script also creates a bunch of other scripts on the object to make it respond nicely through MRTK interactions.

* **Objects created through creation menus:** These objects are created at runtime through the object creation menus. Use this if you need users to spawn multiple objects and modify/move them around. They are just like synchronized scene objects but they are created through the menus.
* **How to spawn one while running:** To create one, run the project and select a Cube from the in-world creation menu; it will be spawned for all users, and located under the networked objects root object.
* <picture> <img src="./Spawn_object.png" width="500" heigth="300" ></picture>

* **How to add a custom object into the menu before building the scene:**
* Create a custom prefab for your object
* Make sure it has a Collider (that’s how users will grab it) and also a PhotonView (that’s how Photon will spawn it; and set its ownership to type Takeover). No other scripts are needed, the system will add other scripts when the object gets spawned.
* Put the prefab inside the Resources/CreationPrefabs folder. (This folder will be scanned when users see the menu).
* *Note*, whenever you add a new object, you’ll need to rebuild the project for all users, otherwise the users will not have the object.
* A (disabled) Iulian’s Room 3d object; you can enable it so you feel part of a room.


* **Next Steps**
* see [Documentation](./) about multiplayer objects; about the code; about arduino; etc.

0 comments on commit 8dea143

Please sign in to comment.