MoveAvatar.cs
To enable this mode you have to select “GPS” under “motionMode” in the LocationManager inspector. In this way the location manager gets the location coordinates from the GPS device of your smartphone, converts them into unity vectors, and tells GoMap to build the terrain tiles.
Your avatar group has to have the “MoveAvatar.cs” component attached to it and linked with LocationManager and your character prefab.
Basically when the app is running it works like this:
- Location manager receive the location updates from unity GPS apis and sends events to the registered classes: GOMap and MoveAvatar.
- GOMap builds the nearby map.
- MoveAvatar receives the new user’s currentLocation and converts it to Vector3.
- The linked character is rotated accordingly to the motion direction.
- The main camera keeps orbiting the character on the xz plane.