I know there are many posts/questions on touch drag, but everything I found normally involved a camera angle that was a multiple of 90 degrees.
I have a game for mobile devices that has a 60 degree camera angle, and we want users to be able to drag objects. The only issue is that dragging up and down on the screen affects both the Y and Z position of the gameObject to where its slightly off the finger, but follows it for the most part. I also don’t want to move the Y position of the gameObject
my basic function is:
while(touched)
{
thisTransform.position = mainCamera.ScreenToWorldPoint(Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y, (thisTransform.position-mainCamera.transform.position).magnitude));
thisTransform.position.y = 0;
}
I’ve also tried using an offset version:
var offset : Vector3 = thisTransform.position - mainCamera.ScreenToWorldPoint(Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y, (thisTransform.position-mainCamera.transform.position).magnitude));
while(touched)
{
thisTransform.position = mainCamera.ScreenToWorldPoint(Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y, (thisTransform.position-mainCamera.transform.position).magnitude)) + offset;
thisTransform.position.y = 0;
}
The first code block works perfectly fine when using say a 90 degree camera, but that 60 degree angle throws it slightly off (and no I can’t change the camera angle). Any suggestions?
i'll try to figure out how to implement that. is this example similar to what you are talking about? except instead of creating a cube and moving it, you just move the selected gameobject? http://forum.unity3d.com/threads/15802-Plane-Raycast-Example if not, do you think you could help with an example? i'll follow up if i figure it out in the meanwhile
– KamiKaze425pretty sure I got it working using that example and adjusting for my animations. thanks for the lead!
– KamiKaze425The example looks fine. I too would have use the mathematical plane.
– robertbu