Hello everybody,
I’ve been trying to get an object to rotate just as the drag event works in Monument Valley. Here’s an example (skip to 0:13) youtube vid
Also if you happen to own Monument Valley, check Chapter 7 (“The Rookery”), that way you will instantly understand the type of rotation-movement I want to achieve.
So far I’ve tried a lot of things I found on other people’s questions & topics but just can’t get it to work right. Also I’m trying to get it work with the Void OnMouseDrag (). Asking for help here is literally the last thing I have left.
Not sure what else I should say regarding this, my so far Unity knowledge isn’t enough to figure this out by my own. Here’s also the code I last tried. If you feel like helping me then thank you in advance.
Edit: Google Drive link
did a quick project, try to rotate the object from bottom->Right->Top, it will stop halfway and then rotate backwards. If you constantly drag on the X axis it will keep rotating though which is also wrong. On MV, it works just fine when you do a full circle.
Hopefully the last edit: Here’s the final script Pastebin Link
using UnityEngine;
using System.Collections;
public class DragRotateX : MonoBehaviour
{
public int speed;
public float friction;
public float xDeg;
public float yDeg;
public float zDeg;
Quaternion fromRotation;
Quaternion toRotation;
void OnMouseDrag()
{
yDeg += Input.GetAxis ("Mouse Y") * speed * friction;
xDeg -= Input.GetAxis ("Mouse X") * (Mathf.Cos (yDeg/60)*speed);
transform.eulerAngles = new Vector3(yDeg,xDeg,zDeg);
}
}