Log in or register to post comments

Loading Multiple Characters and Motions

January 30, 2013 - 3:46pm #1

Hi,

Apologies if this question has been asked before. The project I'm working on is a personal one and it involves four different characters which means four different character rigs, models, textures, motions, etc. What I have now works, but it's intermitten. How it's set up is that all four character loads at once behind a texture GUI that covers the whole screen. I'm using this as a cover. Then when you tap on the welcome screen, 3 or the characters are hidden and one remains. On the AR Camera screen are four stationary buttons. One for each character. The whole point is that you can touch each button and that character will show while the others are hidden. So the problem is this.

1. When I point the camera at the image target and wait for 5 seconds before touching the welcome screen to go into the scene, the whole thing works and I can touch each button to rapidly switch from character to character.

However,

2. When I point the camera and immediately touch the welcome screen enter the screen, it takes a second for the first character to appear and when I try to switch to another character, the one that was there hides and then it hangs for a long time.

So, my question is,...

1. Should I just seperate each character as it's own augmented scene? And how is that done? If you've seen the James May Science Stories app, how is each agumented scene seperated yet all in one app?

2. I'm using Activate/Deactivate to show/hide my characters. Is there a better way to do this in Unity?

3. Is there some setting you can set in the ARCamera or ImageTarget that would make the scene work better?

 

Any help would be greately appreciated. Feel free to contact me through my site - www.3david.com

 

Loading Multiple Characters and Motions

January 30, 2013 - 6:40pm #6

OK, after trying all day, I've settled on a work-around solution. I started by tracking in all the characters at once and then set each button to set the scaling of each character. So, one character is sized correctly while the others are scaled down to nothing. Amazingly it actually works. No delay at all between character switching. Hope this work-around is helpful to others.

 

David

Loading Multiple Characters and Motions

January 30, 2013 - 5:26pm #5

I'm sorry to say, I'm not programmer by any stretch of the imagination. I'm using Playmaker with Unity, the visual scriptor. Currently, all four characters are parented to the image target. The buttons are shooting set actions to show/hide each character. It's just that, the re-targeting of those characters are not happening automatically by the AR Camera. So, what can I do? Do I need to alter those scripts you mentioned? And how should that be done?

 

David

Loading Multiple Characters and Motions

January 30, 2013 - 5:07pm #4

OnTrackingFound is only fired once each time the target is detected. So if you are tracking a target, and want to reassign the model while it's being tracked, you'll need to render the model and make it a child of the target using your button logic, within OnGUI(). You can use the same code as in OnTrackingFound to do this. 

Post the code you're using if that doesn't make sense.

Loading Multiple Characters and Motions

January 30, 2013 - 4:45pm #3

Hi, Did some more poking around and have discovered that the augmented scene isn't hanging, but rather, the AR Camera needs to re-lock to the image target. So, when I launch the scene, one character shows up like it should, then when I touch a button on screen, the character hides and the another character is supposed to appear, but it doesn't unitl I move the iPhone off the image target and then bring it back to re-lock. Then the other character apprears and so on until all the characters are loaded for the first time and then I can finally rapid swich between characters.

So, is there a way to pre-load all the characters into the ARCamera?

 

David

Loading Multiple Characters and Motions

January 30, 2013 - 4:45pm #2

Have you tried enabling / disabling the renderers for these models, rather than activating / deactivating the model's gameobject? The latency you're seeing may derive from the activation process. 

There's an example of how to obtain the renderers for a model in the DefaultTrackableEventHandler script.

e.g.

    private void OnTrackingFound()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();
        Collider[] colliderComponents = GetComponentsInChildren<Collider>();

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }

        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
    }

 

If that's still too slow, you might try rendering them offscreen and then assigning the selected model as a child of the ImageTarget. So you're effectively hiding them until they should be presented on the target. 

Log in or register to post comments