Log in or register to post comments

Moving object by tilting image target?

December 9, 2012 - 1:30pm #1

I've been trying this for a fw days now.I want to move the 3d object which is generated on the image target by tilting the image target printout.

 

I think I saw an implementation somewhere wehre the developer generated a maze game on a business card and the user could tilt the card to guide the game through the maze.I'm trying to achieve somthing similar.

 

So far,I tried creating a plane above the target but the ball would only stay static on it after it falls on it.The ball is a rigid body...

Also tried attaching the following js to the plane,ball and image target (one at a time and even combined) but it does not give the desired output

 

#pragma strict

var speed = 10.0;

function OnGUI()
{
   if(GUI.Button(Rect(10,10,50,50),"X"))
   {
     Application.Quit();
   }
}

function Update ()
{
   this.transform.position.x += -Input.acceleration.y/speed;
   this.transform.position.z += Input.acceleration.x/speed;
}

 

Any help on how to achieve it would be greatly appreciated! And yes,I did search anc came up with just one thread with a similar problem ,however ,I think they decided to further discuss it in PMs so it didnt have the final solution or maybe I couldnt understand it for my lack of knowledge

Moving object by tilting image target?

July 19, 2018 - 10:14pm #52

Hi, I have found a way to achieve such an effect.

The trick is to set the world center to Device Tracking, and set the tracking mode to be rotational, so that the camera moves according to device gyro, while the image target can stay relatively still. 

This is not the perfect solution, as there is always some offset in the image target angle, makes it not completely flat when it is resting on a flat surface. But the offset is usually within 10 degrees, so if you make a ball that ignores tilt within 10 degrees, it will work.

Moving object by tilting image target?

July 1, 2015 - 4:04am #51

I'm in the same situation here, The script is not working on Unity 5 with new vuforia SDK, anyone can help us with this.

Thx in advance

Moving object by tilting image target?

June 29, 2015 - 9:11am #50

Hey guys,

does anybody have a working solution, with Unity5 and the newest Vuforia SDK?

I think it shoud work with one target and with world set to that target. With the given rotation of the camera and the rotation given from the accelerometer/gyrometer it should be possible to calulate the real world rotation of the marker and therfore apply a custom gravity to fake the effect. It's just that I'm not fit enough yet to figure out which matrix/quaternion operations are required to calculate the markers real world rotation.

Anybody fit here? :D

 

Thank you so much

Cheers

Patric

Moving object by tilting image target?

April 25, 2015 - 12:09pm #49

We are not an expert in unity and vuforia, yet we enjoy experimenting both of them whenever we get time and today we solved your problem of " moving object by tilting image target ".

It's as easy as drag and drop ................ NO SCRIPT REQUIRED !!!!

Here is the link to the result that we got through our method of moving the object by tilting image target :

https://www.youtube.com/watch?v=Q3s2vIjd6Xk

Moving object by tilting image target?

April 11, 2015 - 6:51am #48

the code doesnt work now i made the changes to the scrips in unity 5 but the sphere just flies in a random direction

Any Ideas??

 

Moving object by tilting image target?

October 23, 2014 - 1:17pm #47

Hi,

 

I'm tryng to archive the same result and would like to ask if somebody has found a solution for this.

Is the fordavid zip still available some where ?

It would be awesome. Thank you very much.

 

Greetings 

Patric

Moving object by tilting image target?

September 27, 2014 - 2:12am #46

http://docs.unity3d.com/ScriptReference/Input.GetButton.html

Kindly follow this link and customize script according to your choice.

Moving object by tilting image target?

September 26, 2014 - 4:31am #45

Hi, 

it has been several month from your request. Do you have any solution?. I am involved in the same problem.

Shooting Game Objects

July 13, 2014 - 2:48am #44

HI

Actually I want to throw gameobjects like Shooting Bullets But it does not work. It throws unlimited gameObjects without any wait. Here is My script on ARCamera

//Script starts

var prefabBullet : Transform;
var speed : float;
 var gameObjects : GameObject[];
 
 
function Update () 
 
{
 
 Invoke("Shoot", 2.0f);
 
}
function Shoot ()
 
{
yield WaitForSeconds(3);   
var instanceBullet=Instantiate(prefabBullet,transform.position,Quaternion.identity);
instanceBullet.rigidbody.AddForce(transform.forward*speed) ;
 
SomeFunction();
       
   }
  
 
function SomeFunction(){
 
    gameObjects =  GameObject.FindGameObjectsWithTag ("Player");
 
    for(var i = 0 ; i < gameObjects.length ; i ++)
        Destroy(gameObjects[i]);
 
}
 
I want to throw gameObjects between some time elapsing.
 

Moving object by tilting image target?

July 7, 2014 - 9:57am #43

Hi, 

now the gravity work, but if I move the Target my ball is fixed,

I'd like to have this effect https://www.youtube.com/watch?v=MvlHXKOonjI

Regads,

Maurizio

Moving object by tilting image target?

June 29, 2014 - 5:27am #42

thank you, I try to apply on  project

Regards,

Maurizio

Moving object by tilting image target?

June 28, 2014 - 11:41am #41

I really must re-host that file. I'll look at making sure it works in the latest build at some point too. 

Moving object by tilting image target?

June 28, 2014 - 11:25am #40

Hi, My apologies. A couple of people hae asked about this script. Here it is. There are two of them. One for the gravity and one for the Default Trackable Event Handler. You may have to modify it a bit because these scripts were for an older version of Vuforia.

 

David

AttachmentSize
Package icon Ball_Roll_Script.zip2.4 KB

Moving object by tilting image target?

June 28, 2014 - 8:21am #39

Hi,

the file forDavid.zip isn't enable...have you a copy?

Regards,

Maurizio

Moving object by tilting image target?

November 22, 2013 - 11:55am #38
in DefaultTrackableEventHandler have to make any changes too?
still does not work for me

Moving object by tilting image target?

November 22, 2013 - 10:49am #37

I've found the project. Here is the CustomGravity script..

 

using UnityEngine;
using System.Collections;

public class CustomGravity : MonoBehaviour {
	
	public float grav = 380;

	// Use this for initialization
	void Start () {
		//CameraDevice.Instance.StopAutoFocus();
		if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
			Debug.Log ("LEFT");
			
		} else if (Screen.orientation == ScreenOrientation.LandscapeRight ) {
			Debug.Log ("RIGHT");
		} else if (Screen.orientation == ScreenOrientation.Portrait ) {
			Debug.Log ("PORTRAIT");
		}
	}
	
	void FixedUpdate () {
		
		//CameraDevice.Instance.StopAutoFocus();
		/*if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
			Physics.gravity = new Vector3 (Input.acceleration.y * grav , -Input.acceleration.x * grav , -Input.acceleration.z * grav);
		} else if (Screen.orientation == ScreenOrientation.LandscapeRight ) {
			Physics.gravity = new Vector3 (-Input.acceleration.y * grav , Input.acceleration.x * grav , -Input.acceleration.z * grav);
		} else if (Screen.orientation == ScreenOrientation.Portrait ) {*/
			Physics.gravity = new Vector3 (Input.acceleration.x * grav , Input.acceleration.y * grav , -Input.acceleration.z * grav);
		//}
	}
}

 

Moving object by tilting image target?

November 21, 2013 - 9:13am #36

it was forDavid.zip. I only deleted it 2 days ago.

Moving object by tilting image target?

November 21, 2013 - 9:12am #35

Do you happen to remember that the file name of the archive was?

Moving object by tilting image target?

November 21, 2013 - 8:44am #34

It was one target, you are correct about modifying the gravity vector.

I used the accellerometer to establisht he real world gravity vector.

Moving object by tilting image target?

November 21, 2013 - 8:39am #33

Gary did your solution use two targets, or a single target? And were you modifying the gravity vector?

Manusamo the challenge to this sort of application is that you need an independent gravity reference. so that the object responds correctly to the tilt of the underlying plane. This can't be inferred from the ARCamera and ImageTarget transform vectors alone. A second target can be used to establish this reference, by making it the world center. Alternatively you can infer the gravity vector using the cross product of the accelerometer and magnetometer vectors. 

But if you simply want a tilt response, and this doesn't need to match the real world gravity vector, you can try making the target world center so the tilt response is relative to the target orientation regardless of it's real-world orientation.

 

 

Moving object by tilting image target?

November 21, 2013 - 7:30am #32

I was clearing up my server and this file was deleted in the process. Sorry.

I no longer have the files so, unless anyone else does, they're gone.

Moving object by tilting image target?

November 21, 2013 - 7:24am #31
Hi could you re-upload the file
thanks

Moving object by tilting image target?

April 25, 2013 - 9:48am #30

 Hi,  

I managed to get a small game working quite well with this custom gravity script.  Thanks so much for posting this.  My problem was in the fact I had rigid gravity set to on.  

I runs really well now..   As I begin creating my little game  I've run into a few problems with gravity on other objects.. especially entering and exiting a portal... If  a ball for exampe goes through a portal it zips off screen...  

[EDIT]    I'm trying to get  a projectile fired slightly above the target card plane... to fly parallell to the target cards plane  adjusting according to the planes angle.

This is dificult since the Camera world space is set to NONE.     hhmm   ?? 

I'll post my results here once I manage to get things ironed out..    

 Mick

 

 

Moving object by tilting image target?

April 1, 2013 - 6:52pm #29

Hi MickBanks,

If you look down a couple of threads at the step by step, try setting the custom gravity to 600 from what you currently have it set to which is 1.

 

David

Moving object by tilting image target?

April 1, 2013 - 6:47pm #28

Hi,     I really appreciate the script..  nice work  

I managed to get the ball moving but only with normal gravity turned on .. If I turn on the Custom Gravity Script.. the ball just freezes in the air. 

With normal gravity set to 1  & the custom gravity set to off .. the ball it does move  but very slowly.   Not sure why ? 

I'm using Unity4 Pro    & Vuforia 2.  I simply copied the entire  "DAVID " folder into my projects folder & opened it .. the scene loads fine.  

note: I'm creating a little game where a small bear has to dodge the ball .. looks so cute  :) 

Mick

 

Moving object by tilting image target?

January 22, 2013 - 2:16pm #27

Thanks  threedavid for sharing this really nice step-by-step guide;

nice job !

 

Ball Tilt How To Steps

January 22, 2013 - 1:25pm #26

As promised, here are the How To steps to set up the Ball Tilt control.

MUCH THANKS to Gary Riches. He was very generouls with his time when I sought him out on how he put his Bouncing Ball business card together that he posted on YouTube. I think we should all name our first born Gary, even if it's a girl. Gary's a class act.

So here it is.

Note. The files you will need are below in a previous posting by Gary called "forDavid".

Ball Tilt How To Steps
1.       Running in Free version of Unity 3.6 with Vuforia 2.0
2.       Delete Default Camera in the Scene
3.       Add imageTarget to scene
    a.       Set Image Target Behavior Data Set to image target of choice.
4.       Add ARCamera
    a.       Set World Center Mode to “None”
    b.      Load Data Set Behavior to matching Image Target and set to “Active”
    a.       Ensure the AR camera is not rotated around x, y or z axis
5.       Create a Sphere in the scene
    a.       Parent Sphere to imageTarget
    b.      Size Sphere accordingly and place above the imageTarget
    c.       Apply Rigid Body
    d.      Turn off “Use Gravity” option
    e.      Apply “Custom Gravity” script from the "forDavid" Assets folder
    f.        Set Grav to “600”
6.       Copy "DefaultTrackableEventHandler" script from "forDavid" Qualcomm Augmented Reality Scripts folder into your Unity project Qualcomm Augmented Reality Scripts folder.
    a.       Set the Ball Rigid Body to "Sphere"
7.       Create a plane in the scene
    a.       Parent to imageTarget
    b.       Create a box collider
8.       Make sure to set the Default Orientation in the Resolution Player Setting in Unity to "Portrait"
9.       Build and push to IOS device.

 

Well, that's about it. Hope this brings you many fun possiblities.

Best

David

www.3david.com

Moving object by tilting image target?

January 22, 2013 - 8:46am #25

This is fantastic!

No wonder you're so busy :)

Thanks so much for sharing Gary!

N

 

Moving object by tilting image target?

January 22, 2013 - 8:40am #24

*** I am EXTREMELY busy most of the time so can't really offer any extra support, I will keep an eye on this thread ***

This works with the stones target Vuforia always uses.

http://www.bouncingball.mobi/apps/files/forDavid.zip

Here you go. It's a Unity 4 project. 

Notes:

To get this working you need to set the world center to None. That way the target moves and not the camera internally. You then have the issue with "down" always being in local coordinates so you need to work out the real value of down based on the acceleromoeter. In Unity 3 you had to allow for the rotation of the device, it seems in Unity 4 that they have changed things slightly, hence me saying I was seeing strange results. I now only need 1 arrangement of values.

I am only applying the gravity to the ball when the ball is visible. This is toggled from the Default Trackable Event Handler.

The custom gravity is applied in a script that is on the sphere.

This implmementation will allow the ball to be tipped outside of the maze. 

Moving object by tilting image target?

January 22, 2013 - 5:50am #23

Thanks for sharing this with us garyriches. Looking forward to your next update.

Moving object by tilting image target?

January 22, 2013 - 5:34am #22

Hi,

The Bouncing Ball AR card app is my app. The level is made up of cubes so I attach an animation to each cube and play them randomly.

I am creating an example for david to see and whilst doing that I am seeing odd results with rotation and the custom physics needed. Currently I only have it working properly in portrait in Unity. I will finish up the demo and post the example in hte next couple of days when all rotations are working.

G

Thanks for the update

January 16, 2013 - 5:50am #21

Thanks for the update Raaghavv;

just to mention that there is no need to hurry, just when you have something ready to publish let us know.

 

Website in the making

January 16, 2013 - 5:44am #20

A website is certainly on the cards but am faraid it won't be before March.That'd be after my final examinations at University and before the porject presentation.I was just going through a guide on this site that explains how we can have a button in our app to take a screenshot of the augmented scene.I'll include that in my next build and share the pics.

I'm also trying to add force to the ball by multiplying a constant with the values of accelerometer.This may help make the ball flow more fluidly than it does right now.Since am not sure where I should attach the script,am gonna try the AR camera,image target,a plane on which the ball rests and the ball itself.

Have you guys the possiblity

January 15, 2013 - 5:45am #19

Have you guys the possiblity to Post your work in some websites from which we could refer to from here by just posting the link ?

the other option is to Post the "guides/tutorials" which summarize your work here (or better creating a separate new Thread in this Forum and linking to that thread from here), but this would only be acceptable if the stuff that you want to publish is not excessively long...

 

 

Tutorial

January 15, 2013 - 5:09am #18

Sorry for the late reply.Been busy with college festival.

I'll be glad to post a tutorial or small guide on how to achieve the effect that I've achieved.Lemme know what exactly you want in there and if I know a way to do it or if I'd have done it ,I'd gladly share it here.

I'm glad to see that this topic has picked off so much buzz and interest.

It'd, however, help to know what threedavid and others are trying to achieve as ,in my case,it's just a ball rolling freely on the target through a maze full of obstacles.

In the meanwhile,I'd recommend others and threedavid to understand and experiment the sample I've posted already.I'd love to see your two marker approach sample.If you dont wish to post it here you can email me at

I visited your site and I like your work! :)

What I'm Trying to do

January 10, 2013 - 11:30am #17

Hey Guys,

Thanks soooo much these replies. It seems like so many other people are trying to get this image target control effect working. Very exciting. I've seen video of this working, one of which is from a 2010 Vuforia developers competition video on youtube. It's so cool with possiblitles that I think Vuforia should add this as a setup feature in a future release.

This is a simple test for me, but very crucial to nail down. I just want the effect of a fluid ball rolling around the top of the image target as I'm tilting the image target around and if I tilt it too much the ball will fall off and disapprear. Just getting this nailed can open to other rigid body sims like picking up an image target with a stack of bottles or drinking glass. Lots of entertaining rigid body fun!

I would be happy to share anything I've got or PM with anyone. This is my skype user name "threedavid". Would love to open a dialogue when anyone interested in excelling this technology. I would be happy to post step by step tutorial once a "happy" working solution is found.

My professional stie is www.3david.com. You can also contact me through there.

 

David

 

It's very cool to see such

January 10, 2013 - 8:40am #16

It's very cool to see such progress from you guys on this subject;

Raaghavv, if you reach a more mature/stable level of your experiment, it would be great to see a little guide (or a small tutorial) shared here;

this is a very nice topic and probably of interest to many others.

Hi threeDavid, Do you want

January 10, 2013 - 4:50am #15

Hi threeDavid,

Do you want something like when the imagetarget is, say, flipped over then the ball should fall off the imagetarget? Well,I dont know if that can be possible or even natural.The ball is a child of the image target and is a rigid target that obeys gravity.With AlessandroB's script attached to the ball, the gravity works on it only when the it is detected.So when we flip over the target the ball wouldnt be detected anymore.But,isn't that yet natural considering that we dont fall off Earth when we're standing at what could appear to be the lower side of the planet?

Another case would be when you place the starting point of the ball at a height from the image target so that the first time on detection it falls down due to gravity.Now perhaps try moving the image target to the side while still keeping it in view.The ball,however,conitnuing to fall perpendicularly would have nothing to stop it and will conitnue falling infintely , I believe unless you've a collider below to respawn the ball.

Or are you looking for say when the imge target is in  a perpendicular position from the camera,the ball should come off a bit like a bounce effect?For this you may have to tweak the physics settings of the ball.I'm still trying to achieve a very fluid movement for the ball but haven't been able to but then I'm not able to spare much time for my project so I haven't really experimented much but I know it's possible.

If you want the values that am using for my scene,lemme know and I'll post tem here or if there is a PM system then you can reach me through that.You can check out the sample scene I've made below, while for my actual project that I started working on later I just kept the y gravity to efault and the rest is zero.I did tweak the mass and velocity quite a bit to get the ball rolling just fine though not as fluid as desired.

 

If you dont mind ,caould you share the image target sample? I,personally,couldn't get it to work and decided to carry on with one image and it's satisfactory so far.The fluid movement ..and it would be perfect.

 

I wish to post the video but I'll have to either get a tripod or get someone else to shoot it.So,I may not be able to do that until I reach a major milestone.

Hi David, have you tried

January 10, 2013 - 2:26am #14

Hi David,

have you tried adjusting the following:

1 - the initial distance (height) of the ball from the target on which it should roll (maybe try to set it a bit higher to first check if at least it is falling down on the target in some "natural" way; then as a second step you can check if it also "rolls" on the target)

2- maybe change the physics settings like the gravity force, etc. One thing to note is that the Gravity force value has quite an impact, and you might need to adjust it to take into account the scale of the world you are using (e.g. I think a target in the ImageTarget sample has a scale of about 200, so perhaps you might need to increae a lot your gravity force value....)

 

2 image target method

January 9, 2013 - 4:18pm #13

Hi,

I just went through and tried the 2 image target method and it kind of works, but it works really, really badly. The reaction time is non-existent and inaccurate. Are there any setting tips or something else that may help to get this near somewhere civilized?

 

David

2 image target method

January 9, 2013 - 11:30am #12

Hi,

Thanks for this bank of info. I'm trying to get this thing working as well. If I understand what's being said here, the main hurdle is that gravity is perpendicular to the image target. This may be a simple stupid question, but can you simply tell vuforia to obey a global vertical gravity no matter what the orientation of the image target? Or is the 2 target method the work around to trick vuforia to behave this way?

Sorry, just learning all this and trying to figure it out.

 

David

Alright, it's been some time

December 28, 2012 - 3:51pm #11

Alright, it's been some time now since I got back and this thread sort of died.Sorry.

I did try that two marker approach but I dont know if I couldn't get it to work or it's just that even on doing it correctky it simply won't generate the desired output.I've been busy with my final year academics and the spare time ,well , I've invested it in my original approach.Am currently working on that approach to make the movement of the ball as natural as possible,however,it's not as good as I've seen in other games or even here (the bouncing ball ar app developed using Vuforia)

http://www.youtube.com/watch?v=MvlHXKOonjI

I'm going to try this two marker thing again and hopefully soon.While if anyone has any idea on how to "near perfect" the physics so that the ball can move that easy then please share.I'm fine tuning the stuff too and have come a long way from a slow worm ball to something that moves like a bicycle.It just needs a lot of tilt.You can call it unresponsive or maybe adding force to the direction in which the ball mvoes should do the job?

 

P.S. If anyone watches the video and has an idea on how the level builds itself (animation being played or something else?),do post..it's quite awesome!

Moving object by tilting image target?

December 11, 2012 - 8:31am #10

Hi, I will take a look at your demo in the link you posted, as that sounds a pretty interesting experiment.

About the "Pose" matrix approach; that is the same (just explained with different wording) of what you have already tried (setting the World Center Mode to "NONE").

So, there is actually just two approaches: the one you tried and the one with the 2 markers.

About the fact that your app currently works when the camera looks down (vertically), this is because you have defined your Camera to look down in your Scene in Unity; if you change your camera orientation for example to look down with for istance a 45 degrees orientation, then the App will work with that orientation (i.e. if you hold your device as looking at the target with about 45 degrees orientation).

However, there is nothing that can support correct physics behaviour and dynamic (moving) camera at the same time, unless you use the two markers approacj.

 

I hope this helps. And thanks for sharing your experiments.

 

 

Moving object by tilting image target?

December 11, 2012 - 8:16am #9

Thank you for the steps! That would be really very helpful! :)

At the end of this post is a link to the demo implementing the method that I was talking about initially.It works as I'd expected.

However,the ball is tad unresponsive and I really have tilt the image target "entirely" to get it rolling.I believe it has to do with the physics so I created custom physics material and attached it to the plane and the sphere.Besides,I changed the mass and the gravity as well ...it seems a bit better but I'm trying to figure out a way to make it more responsive. Any suggestions on this?

And the script you posted is a real help!

I'll try the 2 marker method next and post the result (probably the demo as well in a day or two).I would like to understand that how would the Pose matrix method be different or help me over this method?Right now the image target and phone have to be held parallely and tilting the image target causes the ball to roll.So basically,I have this

ImageTarget ||   <->   || Phone         OR   =====  phone

                                                           ===== image target
In this case,ball stays where it spawns(rather moves to a corner,maybe cause of slight tilt as am using a printout right now)
 
and

Phone
====
|
| ImageTarget
|

The image is now almost perpendicular to camera which causes the ball to move.

So ,we basically have a camera parallel and "static" to the image target.Will pose matrix way help me make the camera dynamic in some way ?? Sorry I cant seem to imagine or understand that atm.

https://www.dropbox.com/s/tkvh2ye0eic0awh/Maze.unitypackage

It's the entire demo project (probably has unwanted stuff) and kinda unorganized atm.There are two textures (for the plane and the ball).
There are two scenes.It's the BallMaze scene that we are concerned with.There is a custom physics file named "CustomPhysicsForMetalBall" and finally the the script posted is in EnableGravityOnDetection and is attached to the image target as instructed in the last post.
Feel free to mirror the link.

Moving object by tilting image target?

December 10, 2012 - 7:44am #8

OK, sounds great. Let us know about your findings.

Meanwhile, if/when you want to try the 2 markers approach, here is the step-by-step process that I just reproduced here by creating a simple App which does that:

Steps:

-          Create a new Unity project

-          Import asset custom package=> import ImageTargets sample

-          In the Project view, double-click on QCAR-ImageTargets to load the ImageTargets scene

-          Select ARCamera in the scene view and go to inspector, under QCARBehaviour, change World Center Mode to “USER”

-          Drag the Chips target onto the World Center field of the ARCamera - QCARBehaviour

-          Select the Stones target

-          Add a Box collider to the Stones target (Component -> Physics ->Box Collider); increase the Y component of the Box collider size (so that it is for example 0.1 or 0.2, instead of zero)

-          Create a sphere (GameObject->Create Other->Sphere) and attach it to the Stones target (i.e. as child of Stones)

-          Rename the Sphere to “Ball”

-          Position and resize (scale) the “Ball” sphere so that it is located just above the Stones target

-          Add a Rigid body component to the “Ball” sphere, and enable “use gravity” in the inspector view

 

Finally, add the following script to the Stones image target (this is meant to enable the ball gravity only when Stones target is tracked):

 

public class BallStarter : MonoBehaviour, ITrackableEventHandler

{

               

                private TrackableBehaviour mTrackableBehaviour;

               

                // Use this for initialization

                void Start ()

                {

                                mTrackableBehaviour = GetComponent<TrackableBehaviour>();

        if (mTrackableBehaviour)

        {

            mTrackableBehaviour.RegisterTrackableEventHandler(this);

        }

                               

                                OnTrackingLost();

                }

               

                public void OnTrackableStateChanged(

                                    TrackableBehaviour.Status previousStatus,

                                    TrackableBehaviour.Status newStatus)

    {

        if (newStatus == TrackableBehaviour.Status.DETECTED ||

            newStatus == TrackableBehaviour.Status.TRACKED)

        {

            OnTrackingFound();

        }

        else

        {

            OnTrackingLost();

        }

    }

               

                private void OnTrackingFound()

                {

                                GameObject ball = GameObject.Find("Ball");

                               

                                if (ball != null)

                                {

                                                Rigidbody rigidBody = ball.GetComponent<Rigidbody>();

 

                // Enable gravity:

                rigidBody.useGravity = true;

                                }

                }

               

                private void OnTrackingLost()

                {

                                GameObject ball = GameObject.Find("Ball");

                               

                                if (ball != null)

                                {

                                                Rigidbody rigidBody = ball.GetComponent<Rigidbody>();

 

                // Disable gravity:

                rigidBody.useGravity = false;

                                }

                }

}

 

 

Moving object by tilting image target?

December 10, 2012 - 7:24am #7

Alright ,so from what I understand so far is that I've 3 ways to go about it

1. 2 Markers

2. Pose Matrix

3. 1 Marker (World_Center_Mode=NONE ,assuming the start angle of use and thereby allowing the ball to freely move on surface when image target is tilted)

 

I just tried the 3rd way and it seems to be working fine when played from top view (aligned the AR camera to Y axis,I think).I'll experiment a bit more with this way.Right now ,the ball doesn't pick up momentum easily on tilt.It really requires a lot of tilt to start moving but once it starts ,its all smooth then.So I'll play around a bit with physics settings in Unity.

 

Then I'll try the one you mentioned above with 2 markers.I'll report here on how it goes and if necessary (for debug,help,analysis or as an example for others ,incase) I'll upload the work and share the link here.

 

Thanks!

Moving object by tilting image target?

December 10, 2012 - 6:28am #6

Hi,

OK, if you are not too comfortable with 3D reference frames, and you want to try anyway with the dual target, try and follow these steps:

- Create two image targets (e.g. one "Chips" and a "Stones"); let's say "Chips" will be your "World reference" (i.e. the one that stays on your desk and does not move) and "Stones" will be your tilting/moving target (i.e. the one you want to manipulate with your hands)

- QCARBehaviour (ARCamera object, see inspector): change the World Center Mode to "USER";

- Drag the "Chips" target onto the "World Center" field of the QCARBehaviour (ARCemra object, see inspector)

- Attach a "rigidbody" to your "Stones" target, so that it can physically interact with the Ball falling on it

Give it a try and see how it goes.

 

Moving object by tilting image target?

December 10, 2012 - 6:02am #5

Hello AlessandroB! Thank you for your time!

I missed your first reply when I posted the link to the video.Something similar to what you mentioned in your first post is mentioned here

https://ar.qualcomm.at/content/tilting-scene-unity

They do talk about Pose Matrix (though I dont think that I understand any of it).However,from what I understand they got around it some other way which had me thinking that this is easily achievable by just using Unity's in built physics.For that matter I dont think I should even apply the scrpt I mentioned earlier.

 

Now,I can track two images at a time by loading two targets and changing the Max_Targets property to 2 (upper limit is 5?) but then how to go about what you said by having two reference images sounds really complex to me..honeslty,I didnt get any of that.

 

So ,if assuming that the user always starts at a certain point is the other way then I think I'll do with that.My aim is to create a decent working game that would be part of larger suite (my third year project at university).I did have an idea on achieving that by setting world center mode to none but I think it resets to auto everytime I compile and run the APK...bug?For I did try those steps mentioned in your last post but I dont think they worked...only once when I tried using the pdf marker on the screen rather than the physical marker ,it did seem to work and it was very slow and I was under the impression that it is becaus eof the script attached....I'll try again.

Here is the thread where someone has created exactly what I'm trying to create and all using Vuforia but for iPhone ,I believe.

https://ar.qualcomm.at/content/tell-us-about-your-ar-application-or-game#comment-2010417

 

Thank you again.I'm a beginner at Unity and Vuforia but not new to programming so please bare with me.Sorry if it all sounds dumb and noob.

Moving object by tilting image target?

December 10, 2012 - 5:20am #4

Hi, the video shows a case where the camera is in a fixed position, while only the target is moved;

in that case you can assume that the world reference frame is fixed ("froozen") at a known position and orientation with respect to the camera (for instance in the video it looks like the user is relying on the webcam of his PC, and so he can know in advance that the camera is tilted with a certain angle with respect to the "world" reference).

In such a situation, any orientation of the moving target can be referred to such a fixed world reference; however if you have a handheld device (like in the Vuforia case), I wonder if you really want to take that assumption (i.e. that the handheld camera is in a fixed position/orientation and is not moving significantly).

If you make such assumption, then it becomes possible to obtain the effect; you will need to do the following:

1- in QCARBehaviour, change the World Center Mode to "NONE" (instead of "AUTO"); this will avoid that the world reference frame is attached to any target

2- in the 3D view of the Unity editor (ImageTargets sample), change the position / orientation of the ARCamera (in the sample implementation, the ARCamera is placed above the targets and looking down); orient the camera with an angle that will approximately match the expected tilt angle of your camera device when using the App.

That should give the desired result, but again, be aware of the hard constrain that you are assuming, as I explained.

 

 

Moving object by tilting image target?

December 10, 2012 - 4:25am #3

The following video describes the effect that I'm trying to achieve

 

http://www.youtube.com/watch?v=7nKtldKfxvc

 

any takers?

Log in or register to post comments