Log in or register to post comments

Using the same object for multiple targets

August 12, 2013 - 1:44pm #1

I am building an app where I will have four targets. Each target will have a separate animation but it will be of the same character. Is there a way to do this where I don't have to duplicate the same character for each target? I am trying to Limit the size Of the app.

Using the same object for multiple targets

August 12, 2013 - 2:00pm #2

Yes you can assign the model to the target programmatically by defining the model's transform.parent as the transform of the ImageTarget object. This will make the model a child of that target in the same way you do by dragging it onto the target in the Editor.

http://docs.unity3d.com/Documentation/ScriptReference/Transform-parent.html

e.g. in the DefaultTrackableEventHandler OnTrackingFound()

ModelObject.transform.parent = this.gameObject.transform;

It may be helpful to first make your model the child of a GameObject (e.g. ModelObject ) and to reference that object when assigning the parent targets. This will make the scale of the 3D model independent of the local scale of the target, which makes it easier to use the same model for multiple targets.

If you need to position the model on the targets, use the .position and .rotation properties - http://docs.unity3d.com/Documentation/ScriptReference/Transform.html

Log in or register to post comments