[[Tutorial for ver.3]]


* Record and Play Character Movements (Save to MySQL) [#rfc4309f]

In this scene, you can use MySQL to record and play back the movements of characters and some objects.
In this example, you can use MySQL to record and play back the movements of characters and some objects.

** MySQL environment Construction [#be7e0a5b]
** Setting up MySQL Environment [#be7e0a5b]

If you are using MySQL, you need to go through a few steps first.
If you want to use MySQL, you will need to build a MySQL Server. The details are omitted, but the outline is as follows.

First, build MySQL Server. The details are omitted, but the outline is as follows.

+ Install MySQL Server. Operation confirmed with version [8.0.15]. ~
+ Install MySQL Community Server. Operation confirmed with version [8.0.25]. ~
You can download MySQL product from [[here>https://dev.mysql.com/downloads/]]. (Archived Versions [[here>https://downloads.mysql.com/archives/]]) ~
MySQL Workbench is useful.
+ Create a Schema (database) named "sigverse".
+ Create a MySQL user with update authority for "sigverse".
+ Create a table named "playbacker_motion_data" under "sigverse". ~
The table creation script is as follows.
It can be installed using the MySQL Installer for Windows.
-- Setup Type: Developer Default
-- MySQL Root Password: Any
+ Connect to the MySQL Server using MySQL Workbench.
+ Paste the following command into the Query field.
 CREATE DATABASE sigverse;
 
 CREATE USER sigverse@'%' IDENTIFIED BY 'sigverse';
 
 GRANT ALL ON sigverse.* TO sigverse@'%';
 
 USE sigverse;
 
 CREATE TABLE `playbacker_motion_data` (
   `recording_id` int(11) NOT NULL,
   `elapsed_time` int(11) NOT NULL,
   `data_type` int(11) NOT NULL,
   `recording_id` int NOT NULL,
   `elapsed_time` int NOT NULL,
   `data_type` int NOT NULL,
   `motion_data` text NOT NULL,
   PRIMARY KEY (`elapsed_time`,`data_type`,`recording_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
+ Execute [Query]-[Execute (All or Selection)].


In the SIGVerse setting window, set to use MySQL.

+ Click [SIGVerse]-[SIGVerse Settings] in the Unity menu to open the SIGVerse setting window.
+ Check [Use MySQL] in [Define symbols Settings].

#ref(UseMySQL.png)

Since an error occurs in the [Console] tab of the Unity editor, add the MySQL library to the Unity editor.

+ Access [[Download Site>https://dev.mysql.com/downloads/connector/net/]] of Connector/NET. (Archived Versions [[here>https://downloads.mysql.com/archives/c-net/]])
+ Select [8.0.15] for [Product Version], [.NET & Mono] for [Operating System], and click [Download].
+ Access [[Download Site(Archived Versions)>https://downloads.mysql.com/archives/c-net/]] of Connector/NET. 
+ Select [''8.0.15''] for [Product Version], [.NET & Mono] for [Operating System], and click [Download]. *NOT 8.0.25.
+ When you unzip the downloaded zip file, confirm that MySql.Data.dll and Google.Protobuf.dll exist in the "v4.5.2" folder.
+ Copy the two files by drag and drop into [Assets/Plugins] on the [Project] tab.
+ Confirm that the error on the [Console] tab has disappeared.

#ref(MySQLLibrary.png)


** Startup Procedure [#t3463616]

//Start the [Assets/SIGVerse/ExampleScenes/Playbacker/Playbacker(.unity)] scene with reference to [[here>Tutorial for ver.3#open_scene]].

Follow the steps below to run the Unity example scene.

+ Open the SIGVerse project in Unity.
+ Double-click [Assets/SIGVerse/ExampleScenes/Playbacker/Playbacker(.unity)] on the [Project] tab to open the target scene.
+ Click the play button at the top center of the Unity to play the scene.

** Recording to MySQL [#kb03705c]

+ Select [Database Recorder] for Mode.
+ Make some settings such as [Unique ID] and database connection information.
+ Make some settings such as [Unique ID] and database connection information(User, Password).
+ Click the [Start] button to start recording to MySQL.
+ Operate the character with the arrow keys. ~
(Click [Baby icon] to show/hide the panel.)
+ Click the [Stop] button to stop recording to MySQL.

Unity (The details may differ from the latest version)
#ref(PlaybackDatabaseRecording.png)


** Playback from MySQL [#e12bcc33]

+ Select [Database Player] for Mode.
+ Set the same database connection settings and [Unique ID] set in the above recording procedure.
+ Press the [Start] button to start playback. ~
(Click [Baby icon] to show/hide the panel.)
+ When the [Stop] button is pressed or the recording time elapses, playback ends.

Unity (The details may differ from the latest version)
#ref(PlaybackDatabasePlaying.png)

----
''Reference Video'' ~
''Reference Video'' 
#youtube(TO4rDd6j3qE)

Front page   Edit Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes