Log in or register to post comments

Rotate AR object about 360 degree in unity

September 17, 2015 - 11:00pm #1

I have  a Game Object in unity vuforia .so far i can rotate the object left and right when an Image target is detected .Is it possible to rotate it in 360 degree using touch?

Thanks.

Rotate AR object about 360 degree in unity

September 20, 2015 - 10:58pm #3

using UnityEngine;
using System.Collections;

public class Rotate : MonoBehaviour {
	public Bounds bounds;
	public float speed = 1.0F;
	// Use this for initialization
	void Start () {
		var collider = gameObject.GetComponent<BoxCollider> ();
		if (collider == null) {
			collider = gameObject.AddComponent<BoxCollider>();
			Debug.Log("No Collider is Detected");
		}
		bounds = collider.bounds;
		
	}
	
	// Update is called once per frame
	void Update () {
		
		if(Input.GetMouseButton(0)){
			if(bounds.size.magnitude > 0){
				var dtx = Input.GetAxis("Mouse X")*speed;
				var dty = Input.GetAxis("Mouse Y")*speed;
				var pivot = bounds.center;
				
				transform.RotateAround(pivot,Vector3.right,dtx);
				transform.RotateAround(pivot,Vector3.forward,dty);
				
			}
		}
	}
}

 

Rotate AR object about 360 degree in unity

September 18, 2015 - 11:26am #2

This is an application problem, not related to Vuforia. What you can do depending on what you want to achieve is to create a script which you can attach to your 3d object and implement a touch event so while it is not released the rotation of your object in the Z axis for instance is modified.

Log in or register to post comments