Log in or register to post comments

Control 3D objects on a image target by joystick.

July 20, 2012 - 12:22am #6

Hello everyone.

I want to make a demo that control 3D objects on a image target by joystick.

I download a Unity demo here: http://kuai.xunlei.com/d/LMZICFRFYDCM, in this demo, you can control a boy by joystick.

I modify it to a AR project, import Unity Extension package, add ImageTarget and ARCamera, delete old camera,and move boy as a child of the ImageTarget. I test it on my iphone, everything is ok, but the boy just marked time, and cann't walk around on image target.

 

I didn’t learn much about Unity.  any one can help?


Thanks!

Control 3D objects on a image target by joystick.

July 20, 2012 - 6:56am #5

Hi jove

It is not clear to me what you mean when you say "the boy just marked time"

...presumably he just stands still?

If so, then he probably is not getting the update loop that will let him walk around.

Can I suggest you look at the code I posted up regarding rotating a teapot in Unity which will show you how the update loop works, and then hopefully you can see how you might apply this to your scenario.

https://ar.qualcomm.at/content/how-change-way-objects-appear

 

HTH

N

 

Control 3D objects on a image target by joystick.

July 20, 2012 - 7:16am #4

Hi NalinS, thanks for replying. I this modified demo, the boy walked, the "walk animation" played, but can't change the position.

the related code is:

 

    public void setHeroState(int newState)  

    {  

        int rotateValue = (newState - state) * 90;  

        Vector3 transformValue = new Vector3();  

        animation.Play("walk");  

        switch(newState){  

            case HERO_UP:  

                transformValue = Vector3.forward * Time.deltaTime;  

            break;    

            case HERO_DOWN:  

                transformValue = -Vector3.forward * Time.deltaTime;  

            break;    

            case HERO_LEFT:  

                transformValue = Vector3.left * Time.deltaTime;                    

            break;    

            case HERO_RIGHT:  

                transformValue = -Vector3.left * Time.deltaTime;  

            break;                

        }  

        transform.Rotate(Vector3.up, rotateValue);  

        transform.Translate(transformValue, Camera.main.transform);      

        backState = state;  

        state = newState;      

    }  

 

Maybe you could download this demo to see it. I'm new in Unity, I don't konw how to modify the code.

 

Thanks.

 

Control 3D objects on a image target by joystick.

July 20, 2012 - 7:37am #3

Can I suggest you check out the Penelope demo on the Asset Store by the Unity guys?  as this is more a Unity issue than a Vuforia one.

This comes with full extensive documentation on how to build a 3rd person platformer, plus implementation of three control systems you can use on the iPhone.

I think this would probably be the best thing, as you can't shortcut learning Unity ;)

HTH

N

Control 3D objects on a image target by joystick.

December 10, 2012 - 4:12pm #2

where can i download the Unity demo here: http://sdrv.ms/MNEC7r, in this demo, you can control a boy by joystick?  the link is broke!!

Control 3D objects on a image target by joystick.

December 11, 2012 - 3:29am #1

Why don't you download the Penelope demo as its a full game that you should be able to customise.

http://unity3d.com/gallery/demos/demo-projects

Some of the other demos are quite helpful as well.

The other thing you could try is Playmaker, if scripting is not your thing.

N

Log in or register to post comments