I have been working on Augmented Reality Kudan's unity SDK. I have seen the tutorials in which the objects seems to be static but when I tried the objects kept on rotating which do not meet my requirements and I am unable to stop the rotation. If you help in stopping the rotation then I shall remain thankful to you!
Asked
Active
Viewed 724 times
2
-
What have you done? have you added some code? By default, the SDK example does not rotate. – Everts Mar 06 '16 at 18:34
-
I have just tried the sample and added my own model and nothing else. – user3599561 Mar 06 '16 at 18:56
-
As fafase has commented, the model should not be spinning. As it also utilises the gyro for the demo, is your gyro working OK in other apps? – MultiColourPixel Mar 07 '16 at 16:20
-
Yes the gyro is working very well. – user3599561 Mar 09 '16 at 11:00
2 Answers
0
Do you mean that the object rotates relative to your own phone rotation? I ran in to this problem, wanting to place a 2D plane perpendicular to the camera in Kudan with markerless tracking. Depending on my own rotation, it would keep the plane in the same world orientation, so that at different rotations it would not be perpendicular. I solved it by hard coding an orientation translation when the Augment object is activated with the MarkerlessTransformDriver.

Geoffrey Alan Rhodes
- 29
- 3
0
I think you should use markerless augmented reality for this and it doesn't require any sdk for that just a lines of code
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class WebCamScript : MonoBehaviour {
public GameObject WebcamPlane;
public Button FireButton;
// Use this for initialization
void Start () {
if(Application.isMobilePlatform)
{
GameObject cameraParent = new GameObject("camParent");
cameraParent.transform.position = this.transform.position;
this.transform.parent = cameraParent.transform;
cameraParent.transform.Rotate(Vector3.right, 90);
}
Input.gyro.enabled = true;
WebCamTexture webCameraTexture = new WebCamTexture();
WebcamPlane.GetComponent<MeshRenderer>().material.mainTexture = webCameraTexture;
webCameraTexture.Play();
FireButton.onClick.AddListener(OnButtonDown);
}
void OnButtonDown()
{
GameObject bullet = Instantiate(Resources.Load("bullet", typeof(GameObject))) as GameObject;
Rigidbody rb = bullet.GetComponent<Rigidbody>();
bullet.transform.rotation = Camera.main.transform.rotation;
bullet.transform.position = Camera.main.transform.position;
rb.AddForce(Camera.main.transform.forward * 500f);
Destroy(bullet, 3);
GetComponent<AudioSource>().Play();
}
// Update is called once per frame
void Update ()
{
Quaternion cameraRotation = new Quaternion(Input.gyro.attitude.x, Input.gyro.attitude.y, -Input.gyro.attitude.z, -Input.gyro.attitude.w);
this.transform.localRotation = cameraRotation;
}
}

Nima
- 3,309
- 6
- 27
- 44

Maaz Irfan
- 81
- 8