Log in or register to post comments

Rotating the object attached to the Image Target

October 13, 2011 - 5:43am #1

Hi Guys,

I made a script which basically will hit a ray from the main camera into the space hitting an object. Each 3D model is attached to an Image Target. Once I've hit the object and move the finger, I should be able to rotate the object. But this is not happening. If I keep the camera steady, and move my finger on the screen, the object won't move it.
But if I hit the object and keep my finger on the object and suddenly I move my Ipad around, my object basically follows the camera, which is not what I want.

Any suggestion on how I can solve the problem?
Many thanks,
GC.

Re: Rotating the object attached to the Image Target

October 14, 2011 - 8:46am #6

Although I changed the transform.rotation with transform.localRotation, but nothing changed.. I don't understand :(

ksiva wrote:

The above would matter if you were manipulating your transforms in world space. You should be manipulating them in local space (e.g. Transform.localRotation instead of Transform.rotation).

I'm not sure we can help without seeing the code, can you share your script?

- Kim

Re: Rotating the object attached to the Image Target

October 14, 2011 - 8:31am #5

Uhm... that' is something that I didn't considered actually! It could be the right direction... this is an example of code each object has attached.
where transform is the object attached to the image target.

//This is for the MouseDrag
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
		
		if(objectHit) {
			targetQuat = ShootRay() * offSetQuat;
			
			var endQuat: Quaternion = Quaternion.Slerp (startQuat, targetQuat, Time.time * amountToInterpolate);
			
			transform.rotation = endQuat;
 			startQuat = targetQuat;
 		}
}

many thanks

Re: Rotating the object attached to the Image Target

October 14, 2011 - 6:54am #4

The above would matter if you were manipulating your transforms in world space. You should be manipulating them in local space (e.g. Transform.localRotation instead of Transform.rotation).

I'm not sure we can help without seeing the code, can you share your script?

- Kim

Re: Rotating the object attached to the Image Target

October 14, 2011 - 3:25am #3

Hi Thank you for your reply!,

but I was wondering what it has to do with the possibility to manipulate the object attached to the imageTarget.

I tried to change all the three options but the behaviour is the same :(

thanks,
GC.

Re: Rotating the object attached to the Image Target

October 13, 2011 - 2:49pm #2

This might have something to do with how the ARCamera moves in the scene, which depends on your World Center Mode setting.

AUTO:
The first trackable found is used to move the camera (i.e. the trackable stays still in the scene while the camera moves around it). All other trackables are then moved in relation to the camera.

USER:
Same as above, but you can select a single trackable to act as the world center, and it never moves in the scene.

NONE:
The camera never moves, instead all the trackables move around it.

- Kim

Log in or register to post comments