- Home /
Touch input on IOS C#
Hey everyone.
I've been working on a iPad project, for some time now, but so far i've been using OnMouseDown() etc to select, drag object around.
The problem now is that i need to be able to do two things at the same time.
I need to be able to have the object selected, and at the same time with another touch, rotate the object in the direction the touch is moving.
But for this thread, i was hoping to get some help "translating" the mousedown code into touch code.
private Vector3 offset;
private Vector3 screenPoint;
void OnMouseDown()
{
offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
drawLine = true;
}
void OnMouseDrag()
{
Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
transform.position = curPosition;
}
void OnMouseUp()
{
drawLine = false;
IsMouseDown = false;
}
This is the code I'm using right now, not saying it's good or anything but it works, just not for my purpose aymore.
Would love it if you guys could help me out! Thanks in advance
If you need me to add any other code / clarify anything let me know!
p.s if you happen to have a good solution for the rotate problem aswell I'm all ears.
On$$anonymous$$ouseDown(), On$$anonymous$$ouseDrag() and On$$anonymous$$ouse() up will automatically work with touch.
Robertbu - I know that, as i wrote I'm using it now. However as far as i can read / have tried, it wont allow two inputs?
I usually write something that work directly with Touches if I need mul$$anonymous$$ch behavior.
Your answer
Follow this Question
Related Questions
Children ignoring Parent control. [Solved] 1 Answer
Translating JS to C# error 1 Answer
rigidbody.MovePosition & translation 1 Answer
Translating an Array of Transforms 1 Answer