Project FilesIf you are unfamiliar with Augmented Reality, this article could introduce AR to you
Make
sure you have a camera connected to your system, it is preferred if it is not
fixed. easier to control.
Make
sure to Print the makers from the location:”AssetStreamingAssetsTrackingSamples” t1.png & t2.png
Open
Unity3D with OpenGL Render mode, use the command “Unity.exe
-force-opengl”
Scene
is in “StreamingAssetsTrackingSamples” Folder Double click on it to
open the project
After
Opening the Scene:
Expand
MetaioSDK object
You
will find two objects with the name “MetaioTracker”
If
you click on any of them, you will see in the inspector tab “Coordinate System ID” This
is the Id number which specify which Marker image is associated with this
marker.This information is predefined in the XML File
“TrackingData_MarkerlessFast”Located at the same folder as the markers
“AssetStreamingAssetsTrackingSamples”
If
you expand the “MetaioTracker” objects you will find:
o in one of them
an object called “Max”
o and in the other one
an object called “Tyrant Zombie”Those are the 3D models which they will appear when their parent tracker will
detect the associated Marker (pointing the camera to one of the printed
markers)
You can alternatively remove those models and add your own.
The
model “Max” can be controlled with the keyboard: Movement (W,S,A,D)
The
model “Tyrant Zombie” is associated with an AI system
sight rangehe will start following him
attack rangehe will start attacking him(at this sample no health system is not applied)
This sample has an issue:If the “Tyran Zombie” tries to switch his direction it model will be
flipped in a weird direction.I am suspecting this is due to the Up Vector and the way it is implemented in
the AI engine (R.A.I.N)because AI usually use “transform.LookAt” or
“Quaternion.LookRotation” and pass the default UpVector (0,1,0).
Assuming that UpVector is to parallel to the Y-Axis
But with this sample; Metaio SDK will keep changing the position of the markers
based on the camera movement so the look stable while we are moving it.
Thus UpVector is not (0,1,0) always!
I wrote small Script you can find it at this location
“Asset/TrackingSamples/AI.CS”
and attached to the “Tyrant Zombie” by default it is disabled
(because I am using the R.A.I.N engine)
The script will make the “Tyrant Zombie” always toward at
“Max”.
In this script, I did not use the Default value for the UpVector but I kept
recalculating it for every frame from the Tracker position.
Therefore, I got more stable movement, and the “Tyrant Zombie” will
not flip.
To
test this script:
Object and
check box Top-Left at the inspector).
object and
script
Note:
I used UnityVS add in to make edit and view the code in Visual StudioYou may have to go to:
o “External Script Editor”
to choose your preferred Editor.
